|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' i; W/ ?7 |8 P0 T8 W& _; v
#include <linux/init.h>
7 o5 _1 u! e7 K5 \$ o; A$ y: f7 S2 B$ ]#include <linux/module.h>2 g5 Y! J6 ]; R1 b* L
#include <linux/kernel.h>
! E2 c* |* K5 U#include <linux/types.h>" G1 P+ ~7 t5 o1 n8 V9 B
#include <linux/gpio.h>
4 z: e2 i' p" L% v0 i9 C8 ~$ [#include <linux/leds.h>: ^1 z2 X( ]; R \; q7 E F
#include <linux/platform_device.h>3 p# k! |9 X/ L7 Z
! {$ y% b( B, _
#include <asm/mach-types.h>
5 I& c5 g( X: e0 s#include <asm/mach/arch.h>
/ V, X5 x/ A- f5 m* ^5 @* t#include <mach/da8xx.h>- U) Z1 x+ @( }/ u; L* [" y
#include <mach/mux.h>) t( ^( Q) F4 j- A
; t3 z4 h M8 R0 z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 ?% Y/ w; y' A# T2 y9 \
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' _7 r _% i# g' U#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) M% g3 H I# x6 N( n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# G4 t/ w/ \4 u6 E
& \) e4 s3 X1 R
/* assign the tl som board LED-GPIOs*/1 r5 L8 Y C/ {/ N0 u# A) w* k) K
static const short da850_evm_tl_user_led_pins[] = {
! i- i6 ^/ X Q' a6 }9 l /* These pins are definition at <mach/mux.h> file */
+ d3 j, x$ C9 m. o6 E+ A8 A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
i3 J6 p$ K5 |5 b6 t -15 u2 ~% I& |; {' U) K9 N' \* T3 o
};
) H. y* ?) u1 R
" ` f) Z: D% J( S9 _! `static struct gpio_led da850_evm_tl_leds[] = {& I! H- A8 Y$ w8 j
{ {2 q4 R' X, O! t# z6 u
.active_low = 0,$ t" c2 D2 t$ L; a, d$ V7 n
.gpio = DA850_USER_LED0,9 j9 W; A3 c* Z8 o
.name = "user_led0",
$ e( J, D$ w, W6 U% R* h .default_trigger = "default-on",6 \* K& S% o2 T+ y% g
},
4 Y* I3 X" a4 B9 {, E {
/ N, H8 J3 i1 g( X+ W# U .active_low = 0,
5 }; K1 s3 O% x$ ?9 u6 _2 A .gpio = DA850_USER_LED1,+ y4 M1 @& u+ _% L, D' C: \
.name = "user_led1", h: |7 r. k$ d& P) o9 _
.default_trigger = "default-on",( P6 F( u* P" n7 v# j: |
},
- P0 o- r4 r) o: }' X {; Q5 h5 J: W6 V: d$ c+ Q) g
.active_low = 0,% H- K0 [; _9 z) a. y5 F# f/ n
.gpio = DA850_USER_LED2,
6 C1 B. W6 [% r+ _8 @ .name = "user_led2",) |$ [5 e& L* f( h
.default_trigger = "default-on",( J6 n$ ]1 | [: }! ?2 ^7 o
},# p4 d7 p3 V# z3 \5 d
{( y; t" K' j- {; M2 Y8 L
.active_low = 0,6 W3 A& P) \/ i) J
.gpio = DA850_USER_LED3,+ {5 } y3 N8 k$ e' ~7 x
.name = "user_led3",
5 P3 r! L3 o2 p8 j! W' c. O .default_trigger = "default-on",
4 k0 m0 D; Q* E7 a. ]! W },1 L w% N: k/ M8 O
};
% A* O$ X8 e. z: d" `! s/ Y$ L
! T C# T9 K3 J: B5 a Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 |2 ]2 }( e3 r2 |
.leds = da850_evm_tl_leds,! Z! ]* A. z3 }7 \* Y, p# [# ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 B: O9 K9 o2 }+ t) x7 | k8 J! n
}; F2 V0 k" M y ~, Z- r
# g% B" V1 Q* Ostatic void led_dev_release(struct device *dev), G }+ T* S" C; R2 ~+ Z5 _
{1 a3 `8 H M1 t6 _8 J+ ^0 q( P
};
' H6 C3 l" X/ s4 ~! u# L; l% r+ b8 H0 }% J9 H ^$ Q: |
static struct platform_device da850_evm_tl_leds_device = {
$ E4 r/ U- m9 j .name = "leds-gpio",
" f0 k x4 m y- ]% h3 m .id = 1,
7 S( `7 q( L, E* e- d& u .dev = {
2 `$ q- c% V6 z# H6 H .platform_data = &da850_evm_tl_leds_pdata,
: x6 x* }# N# X0 R .release = led_dev_release,
2 L" i! J+ [5 W" Z; T2 }9 U }
7 a* ^ X/ ~& @ g9 D7 x3 T};
% k3 z* K3 l' s+ o
2 z" P4 e8 M6 V( rstatic int __init led_platform_init(void)$ _; b" j W7 `$ z2 {
{
( Y4 |8 V. _( o' N' ` int ret;7 \# X8 z- q9 n
#if 0
- V' K; I' S. K! b% p! H0 p5 Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- e4 F- g' B/ H: w2 W) }6 n# p) I
if (ret)
) f" H! {& k: h A9 D# R pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' X* {: x8 z$ X7 R. `& L6 g, M: s "%d\n", ret);
4 K+ {) ]* j% N6 `- g+ v6 o+ G+ s* b#endif4 c: `) P* u2 ]: W* ~+ z
ret = platform_device_register(&da850_evm_tl_leds_device);
& }. G% i! ]* j if (ret)
8 _- ]1 j [% G% H pr_warning("Could not register som GPIO expander LEDS");1 `- ~$ c5 P1 c4 g6 i
else
/ |, Y5 ?) D1 l4 X printk(KERN_INFO "LED register sucessful!\n");
5 W8 i7 g" w8 ?9 h' @ n0 f+ i* w3 L* J# l( `( D
return ret;
. t) D5 J& G' s6 G0 M0 n- B1 e}
1 x* X! n& ~: d" j$ Z1 B( g$ z, T5 s D6 |! k* S6 `% Y2 B/ _
static void __exit led_platform_exit(void)
* q+ k: J) B& n" @{4 |' ~% E+ n3 T3 ` _
platform_device_unregister(&da850_evm_tl_leds_device);( f5 M% H6 z( Y, {' e" v) G
8 @; I) ?) u% h* p8 i printk(KERN_INFO "LED unregister!\n");
( }! O$ C6 c+ S- H}9 S5 \" C! |" s( Z1 ]1 _
3 B- D5 H4 S8 i p a# w; S
module_init(led_platform_init);' ?2 W2 z* Q( k( e) F
module_exit(led_platform_exit);5 Q' l. m9 t4 F, L4 ~* [( ]! a
1 F# b) u2 y6 j1 N! r: L! JMODULE_DESCRIPTION("Led platform driver");& A0 ^+ `6 ]/ @& t
MODULE_AUTHOR("Tronlong");
! n6 }3 W" z5 bMODULE_LICENSE("GPL");
! k# w7 e, f( n9 B; F% o2 F' p7 ] Q' Z4 I
|
|