|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. W9 n( f& V2 m7 w9 c8 e& O* `- Z, F
#include <linux/init.h>4 G/ p8 ~6 Y( R" v
#include <linux/module.h>
/ l7 m0 o9 A9 s2 P* W6 p#include <linux/kernel.h># L4 [$ g0 [, C5 O& J" F
#include <linux/types.h>! f5 w7 i& k( q
#include <linux/gpio.h>7 x5 J W3 c* n
#include <linux/leds.h>
L# G* R0 g% S+ Z: p#include <linux/platform_device.h>
6 E8 n$ o. R# H% o& V* a* t+ r; z" [# a( D
#include <asm/mach-types.h>
! b( y& i; z5 S5 W8 A6 j4 X#include <asm/mach/arch.h>
( h9 Q& Z$ V, V3 D#include <mach/da8xx.h>
5 t5 \0 c2 g, \& T( }* y$ ^#include <mach/mux.h>
+ E8 J P( [- {! C4 \9 r& I) D4 y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 L! M0 F G: k" B2 _0 l3 f. V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ l- a: W$ @4 S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' E' U! j) n1 W#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- w) C4 ^; i' ?9 q( s# u2 L4 m, R
/* assign the tl som board LED-GPIOs*/, x7 b& L9 e% ]* U
static const short da850_evm_tl_user_led_pins[] = {
7 r1 G) _! S* a; e /* These pins are definition at <mach/mux.h> file */
: ]( o5 ~0 T% X) Q$ N, s! \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! ]$ g! F" d% i, U -1% y* K: n9 [" j
};
1 n8 k! P- d9 O l( {
: C d8 P7 c: ]6 a" W, L; kstatic struct gpio_led da850_evm_tl_leds[] = {
4 b) q$ E8 R" r {; q2 f2 Z, ]0 _
.active_low = 0,
' n1 [7 a; j( E .gpio = DA850_USER_LED0,2 n0 P" J' G _
.name = "user_led0",; p: m R& F6 u4 |) M+ e, |
.default_trigger = "default-on",
, b7 Y( l( F" ?1 k# G0 e: I, J },
) G/ j0 P4 l. D# b {
' V$ n5 t$ G: l: [4 g* t" V9 i, D .active_low = 0,# E( k; Z- R! \1 }. s2 A9 L
.gpio = DA850_USER_LED1,! D5 i/ n4 E7 Y. w" i: a
.name = "user_led1",
; y O/ G% o, S .default_trigger = "default-on",; p8 ^. S3 U0 I7 c1 c4 e
},3 r) j% L: o( n+ r$ c. z' A ]
{
; S# s- ]6 Q8 {4 ^ K7 l0 y7 |; B .active_low = 0,- b9 y2 x( o+ c3 K9 g' e1 d0 e: k9 ~
.gpio = DA850_USER_LED2,
2 l# T) Y$ l2 @) s .name = "user_led2",
& D9 g' `7 t. a+ L; F" } .default_trigger = "default-on",; [. m' I3 h! u5 o! ]# K4 V
},5 O: F- e2 F* f7 g& F$ G
{
( O3 a: d9 L9 D, l/ m .active_low = 0,
) l6 a; g3 z) b" G# q0 ^ .gpio = DA850_USER_LED3,
" w; l- ?( Q, H5 T2 C .name = "user_led3",
& F2 W& v4 ]& w( ^ } .default_trigger = "default-on",; L, X, s+ T* Z
},
; _# ?! H7 V! p6 K' m};4 N: ]7 s8 l$ f6 d9 {
* i3 s/ J4 M0 X" N Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 s$ i4 |$ H9 f @
.leds = da850_evm_tl_leds,
- H' t, q/ h5 o) f0 @. h .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* b5 a9 o9 B5 L \" [/ k. W: H};1 J, q: y4 h3 W* m! t' P p
$ c* P* ~& A3 S [' j" h
static void led_dev_release(struct device *dev)
" r- H( k( i$ q& o4 z{
3 A0 n# T: E0 s/ Z2 p};
7 G& }$ e# ~# S
5 _7 }! K0 V( K, M/ Vstatic struct platform_device da850_evm_tl_leds_device = {# D* u$ x% g' z6 z
.name = "leds-gpio",+ j0 v4 L! X! j& M& L+ m! Y
.id = 1, K: o8 z$ U+ V2 r" t
.dev = {% Y J( H) j# V+ e& v+ H" J
.platform_data = &da850_evm_tl_leds_pdata,' }7 ^6 v9 E/ m! H# A/ d3 W- S
.release = led_dev_release,
$ i* O. v+ j" L/ O }
5 t5 L G! d3 x0 |8 R};
# w/ r3 H8 U& g3 C# ^9 x) v
4 E; u3 y7 @: p, d- K, f7 Vstatic int __init led_platform_init(void)
' `, A& [( O* Z0 e{
* e2 m2 S1 O, a8 V4 _ int ret;8 e( a( K) W& x8 j0 w! i- ?
#if 0$ ~8 m% ?( f8 n o
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 ?4 A, L7 J5 h, `2 x$ e
if (ret)
! {+ X$ I* i+ d1 i8 c' V pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ a& O2 J# y" D! \ "%d\n", ret);
; z' |! ]3 s% Q9 I#endif
$ R. X- `" V6 \" ]: S i ret = platform_device_register(&da850_evm_tl_leds_device);
/ y! {: h5 G& k4 o/ X if (ret)
& m$ O* h) C9 T pr_warning("Could not register som GPIO expander LEDS");- [! \2 o3 p/ F( l2 ~0 H$ p
else+ J, T3 l5 b" O# P" t. A( f
printk(KERN_INFO "LED register sucessful!\n");
0 Y$ s, l1 g. k* f8 t
7 I, G3 M# w) G return ret;# H, }" P7 \: l* E
}
8 G$ i6 x& I# i: a9 _% O
7 f7 @0 i; X/ H7 |! I, D# ]9 @" N+ Bstatic void __exit led_platform_exit(void)
% x+ S) t2 b, O2 `% B{
4 E, x9 N8 U J2 Z% `& k) D7 J platform_device_unregister(&da850_evm_tl_leds_device);1 J: N; W5 i5 H9 n1 z2 q
7 Y3 ]2 k- ]* t6 _- v" b/ _ printk(KERN_INFO "LED unregister!\n");
7 E5 w' q* [: h6 T# ^$ G* F9 a}
; }6 h' V: W4 ` X# _& ?! e
# j# @" L0 x, C9 v7 _ L" Rmodule_init(led_platform_init);
. W6 _2 N$ s- M! f1 f2 e+ Jmodule_exit(led_platform_exit);
4 k0 ?8 S; c" l, p# |; o+ ?- @: z- K2 n) W0 f
MODULE_DESCRIPTION("Led platform driver");9 w% z8 @5 U+ v
MODULE_AUTHOR("Tronlong");$ \' |6 P. X. J9 x# f* k5 x; A/ n
MODULE_LICENSE("GPL");
7 S8 B2 v# c0 ~- j& i
" f; I, S# S% X# k% D2 Q& b" i; y |
|