|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. h) J: o6 _. S* x, J' y
#include <linux/init.h>& v9 F0 x# B8 J* C. w* F
#include <linux/module.h>7 v9 ~2 R8 H* l% ^1 p: `3 @
#include <linux/kernel.h>( W4 ~' k& W9 a4 }
#include <linux/types.h>) q2 t& g' K* H7 w) s
#include <linux/gpio.h>& I" G# f; Z: X! d/ q/ J
#include <linux/leds.h>: F+ N& r5 y9 `$ b% b* G i
#include <linux/platform_device.h>
* w. w; r. J: e# ~) f7 V1 D5 x$ Y9 L5 j8 V% d h/ ?$ \* q/ C
#include <asm/mach-types.h>' d3 Y* v1 H4 \+ [
#include <asm/mach/arch.h>
i0 e8 }8 r( N4 ]1 Y5 q#include <mach/da8xx.h>
$ S q4 Q0 x0 s: W' h6 r#include <mach/mux.h>
. r4 y$ E4 A. O& q" [9 q
8 h$ e/ W, |0 G! f#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ ?5 ]0 b( |6 N8 Z0 ]+ X3 U& f#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; p, [( K# P9 `; r$ F% J1 g/ ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' k5 [) q& u3 `+ e: {8 L7 s# d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- d( }( o& t, r1 A
0 @( z$ R$ p m* s/* assign the tl som board LED-GPIOs*/
. c% `7 x! T% b5 m$ Istatic const short da850_evm_tl_user_led_pins[] = {# V' u9 e; z9 H6 \0 v) m
/* These pins are definition at <mach/mux.h> file */, j- K# ]7 A% d2 g0 c2 \! D4 ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 p7 j5 m9 M' W7 h D -1
; [4 \7 \, h7 i( v& }5 g+ X/ J' Z};9 T9 `; H2 }& b. C( q8 D
$ e- v& i) B5 w' T6 j) r' U# f
static struct gpio_led da850_evm_tl_leds[] = {
6 {- h! A( u. H) Y( r3 | {5 H2 p" L! u4 B5 W/ i
.active_low = 0,
1 J1 s9 w' [# F+ {5 w+ Y: r .gpio = DA850_USER_LED0,
1 n) v7 n$ l8 E3 j, @ .name = "user_led0",0 Y4 W* U: ?4 w. X+ A
.default_trigger = "default-on",
) {' ^4 _' Y! n5 q# E- [ },
- m, X# V8 \' Y: p6 |4 j2 `4 Y {
2 G2 y/ G5 V/ @9 I* G) u .active_low = 0,
8 E$ ^) e* P3 V+ Q9 d .gpio = DA850_USER_LED1,2 H2 M5 `2 N5 o* u6 |9 Z8 k2 v
.name = "user_led1",
* o1 t% h, N) d4 ] .default_trigger = "default-on",
8 c8 x: r4 N4 j2 s" k' p) u) Z },$ C, x* v* H! b
{# [* a& e9 s2 i
.active_low = 0,
. `, p, m; R! i; v z. ~. c1 T- A .gpio = DA850_USER_LED2,
0 h! n2 M7 Z _ g) Q: b .name = "user_led2",& v4 n! i& Z1 w1 E" f9 P
.default_trigger = "default-on",( X' A- r0 f' e; x
},
5 ]% p/ A; q {$ ?: d3 ? {% V$ D5 h/ |9 z2 s) \: z) W
.active_low = 0,
, S- ]4 ~8 q7 j3 B& `0 I- i .gpio = DA850_USER_LED3,
9 o5 V9 R. U, F5 r' r' N c! a .name = "user_led3",
1 K$ U! E7 j8 x) I .default_trigger = "default-on",
: B; }; J: ~: n6 J, B/ Q },
- z. {; w3 c$ Y# ?; a! y* S, ]};4 l" Y* w8 V" o# {! K
# U6 a1 D3 i; A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 \( o8 r; M; V r/ `* U" F
.leds = da850_evm_tl_leds,
4 l+ `1 k* v- d3 d9 l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ y/ @5 C* v. k! G+ i};
& n9 p0 V3 n0 W" D5 R5 }: ^% Z6 C/ I. ]
static void led_dev_release(struct device *dev)& M( K( ], c% A2 k1 e9 s8 D
{- S! `& g z6 v( ~. Z% P+ ]1 k7 C
};
, ~/ j* c7 o) j& H2 ^" k
7 P" A7 C* j h- t2 O3 f4 \+ Rstatic struct platform_device da850_evm_tl_leds_device = {
1 _" x/ _' v2 P' R .name = "leds-gpio",# i" a I2 J5 m" n+ K, Y
.id = 1,, `! I; C, N3 |5 u2 V. B
.dev = {
6 n* A, m0 T% l% l: K* @ .platform_data = &da850_evm_tl_leds_pdata,6 S6 \# _6 z% I, c) c% s$ R* |4 T( S6 d
.release = led_dev_release,
9 t( F& Z( x& p. r }% i' L0 L. R" U$ ^8 v$ e( ]
};
+ T7 ~" T. E5 }" Q# I1 W
* [5 H2 U4 u% L& ?0 s) c! n* l) P; `static int __init led_platform_init(void)
; o- [( q/ h9 K; C{
$ H6 o( S* ]1 @6 |8 V int ret;$ s6 w \( Q0 y' e9 o$ J
#if 0
' v4 |* b( v% s2 g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 ~; x S3 B# ^6 [1 S# L5 z' k- b6 v if (ret) L% X* h$ W5 w+ L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
X7 w/ ?( Y8 H* c! t "%d\n", ret);
! \4 S- z/ Q1 J% i: S#endif9 o' p4 }- m Y: I; }
ret = platform_device_register(&da850_evm_tl_leds_device);
' _: M7 Y9 g& d2 n6 n if (ret) m8 p1 k+ [. |8 n4 o4 J
pr_warning("Could not register som GPIO expander LEDS");
, t. s# \7 E) K else5 r1 ^/ p' w7 l" l
printk(KERN_INFO "LED register sucessful!\n");
( ` S- L/ O7 m5 `8 d! G' o5 f% j* L3 J, C' I0 W: n( R
return ret;
& S- V: w- a& T4 V: X. f6 O4 G2 ?+ b}
" s; A$ ^& Z6 h# J; J# m. H# x* R& ^
static void __exit led_platform_exit(void)
4 y9 G" K/ ?% a; F{6 A: B% d8 e" k
platform_device_unregister(&da850_evm_tl_leds_device);. Y# r: c* p; s5 O
9 x, Z9 z8 ?$ d( S+ d. C' k. N printk(KERN_INFO "LED unregister!\n");
2 k& X6 _$ q: @} D" d& |% O$ X1 ?: J, W& J
: |* l+ F; l0 U3 F# b
module_init(led_platform_init);2 p0 S( X/ T' r* L# Z5 {
module_exit(led_platform_exit);
+ d; }/ E0 ?: B) O2 F1 T$ ?* E5 C; e3 S! Z5 \
MODULE_DESCRIPTION("Led platform driver");6 a6 ~) ~6 m1 i
MODULE_AUTHOR("Tronlong");
7 ^) D. Z+ E( q8 ]* tMODULE_LICENSE("GPL");
# K7 V6 O0 M+ x0 e* ~& E& t6 R- s3 B0 O: {4 Q
|
|