|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* a2 U0 i' R2 J3 N+ ?' O
#include <linux/init.h>" o* n" d6 j8 i" E9 k
#include <linux/module.h>. b1 V6 X/ u. E6 `+ _& n
#include <linux/kernel.h>
2 L2 u q, ?" i( |0 C% C) q" q#include <linux/types.h>) G( F- ]8 j7 h' S6 N* d
#include <linux/gpio.h>
7 H m$ Z! d Q6 c. d1 c#include <linux/leds.h>
1 x' v+ a- q: G# u* w. B#include <linux/platform_device.h>
& ~& W5 z4 s5 B9 a/ R$ B' {; L' Z8 ]) ]* j
#include <asm/mach-types.h>) D' v: \( b6 e0 U' p1 F
#include <asm/mach/arch.h>
6 E6 m+ s# r; W, L/ Z#include <mach/da8xx.h>
0 a3 J) Q3 S w; I- K' w5 z, Y#include <mach/mux.h>
I! V* `& F, |7 \2 _/ j. z, Q* A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( Q3 L. y4 @- o' s; v) W#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ `) g( {8 j9 A; _# Y& @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 o9 ^3 M% ^( q% g; a y4 H
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- v# I2 o% r3 F1 S/ R _% h+ v9 |1 ] u8 b" `/ _5 ~
/* assign the tl som board LED-GPIOs*/
# m) N: y, g9 P" astatic const short da850_evm_tl_user_led_pins[] = {
: v" L" Y( B1 t: C' s! g! G6 N /* These pins are definition at <mach/mux.h> file */
6 n. D( I \7 p y, u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, J L, `/ P" x* O" g7 U* i7 [ -10 R- M3 P, T/ r# w
};
1 x2 R5 N/ }% j# f+ z% }% m( V
* b6 w: Y% ^% ^/ ~static struct gpio_led da850_evm_tl_leds[] = {
0 e. j/ D8 N. `+ b {
& f% k T7 \8 ~5 W# p2 P .active_low = 0,# G: }& j0 S9 m3 Z
.gpio = DA850_USER_LED0," {& S) G0 t( b5 B- C
.name = "user_led0",! l* Y* l* \9 ^% X; X5 `
.default_trigger = "default-on",
, ~" h3 w! B$ u' N' M },7 X; Z* E B% d. V) `! V% h5 X
{
9 P; ]2 `$ i" n w2 k+ T1 x% I* k .active_low = 0,& ~: b5 k6 P% ~; A( T ^ ]
.gpio = DA850_USER_LED1,
0 G; A& P7 k" P1 w .name = "user_led1",
3 {* Q' z1 @$ }6 U% v; t$ Z# c* t$ q .default_trigger = "default-on"," `# Q( Y4 }6 ^4 o
},# ?. T5 d7 Z k! M
{' B& W9 W1 I7 z0 D+ f
.active_low = 0,3 f* ^* T2 V9 v7 |
.gpio = DA850_USER_LED2, z( g& a" ^) Y" {" j
.name = "user_led2",
0 G5 B) b; v, v3 d" D .default_trigger = "default-on",& H. k; y" s* S
},
9 B5 D- a% a3 S' U# x {
( r9 }; e0 h$ h6 U! i6 Y .active_low = 0,
+ w5 R# B/ b& V2 g3 w4 m# c .gpio = DA850_USER_LED3,
/ Z( G4 q3 h5 K" a; x .name = "user_led3",
# |. K$ ?% M% F8 A: |1 w; X .default_trigger = "default-on",% ^1 k0 t5 K9 U& t3 c; E! X- S
},
/ ]% |5 G8 Y$ |1 b};8 B2 w8 _0 E$ P# B! T
5 F& h5 }: v. Z; _; q6 E$ m& @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 ?; _- Q4 W% `7 a3 h6 I
.leds = da850_evm_tl_leds,% W2 D! W6 }/ q5 b0 d V* ?9 X% U
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- F8 M1 [8 |1 k2 D: t4 S/ K};
* {( U0 ]. v" I) o7 q* a
6 f1 l: j( W5 c2 m& J. M! t# Fstatic void led_dev_release(struct device *dev)/ A1 z: s( _# S+ I% A9 D& d
{
, t+ O8 {! G& ?9 A};8 ?" |5 c9 o/ H* X; v! n! L
% T2 j# y6 a0 `' |. z1 Dstatic struct platform_device da850_evm_tl_leds_device = {
& a; n+ S2 ~+ f5 Z# w$ L+ e8 s .name = "leds-gpio",
) c( m8 M- B8 o .id = 1,
2 J7 {- \: C4 K# X& U .dev = {5 d6 \$ \; x& y1 A9 w$ F
.platform_data = &da850_evm_tl_leds_pdata,
. v+ n) v6 t! j5 r b7 g .release = led_dev_release,
* J3 j4 |$ C) ^ }
2 } Y6 O' w7 C};9 O/ B; M }) x9 e V2 n
1 s9 B1 g7 V( R1 dstatic int __init led_platform_init(void)
% c5 L9 N! H8 ` n{
8 D$ W" p+ h) a int ret;
3 v5 x4 `0 l4 { g#if 0
1 X1 g) l# l7 O' W% D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); Q$ a ?* m5 i; |* C
if (ret)- _& t4 T2 Q* p) l0 d% l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% K; o2 t/ V. A8 M8 G9 p* Q& I
"%d\n", ret);
( K0 {$ l6 B B, q E' C$ T#endif* G. t) |+ B0 F
ret = platform_device_register(&da850_evm_tl_leds_device);0 G* t% T) J3 A9 c
if (ret)$ r# o2 y, }1 ~" U' n6 c( |
pr_warning("Could not register som GPIO expander LEDS");
6 j q9 O' o+ S else
, \# m( J# z6 B$ y6 ~/ { printk(KERN_INFO "LED register sucessful!\n");
' X) t- p) C" `& e4 J. u9 V& v8 h. j) G3 A/ [. Z$ j% T h
return ret;
9 @. k0 {* R. q/ x) m}
: C$ H3 x* W. N0 i
7 d9 r/ |8 }% \0 I4 Zstatic void __exit led_platform_exit(void)
7 a/ z4 O" S3 o5 z# o{
- }0 ^: b! E8 L c0 w% k. N; A platform_device_unregister(&da850_evm_tl_leds_device);
& u- O, ^9 h. u' `7 D# s# o
8 |2 f$ L( @ S8 ^- X4 v printk(KERN_INFO "LED unregister!\n");
% N+ e% K1 b0 s6 u+ f}1 m) e! a! u8 d8 k
3 N6 ?# m- l2 N- {1 Omodule_init(led_platform_init);/ l4 ]# @8 y. s8 T: K: Y
module_exit(led_platform_exit);3 J' ^ s( O U% \
$ A% F# ~5 p0 x! Y# cMODULE_DESCRIPTION("Led platform driver");9 d( T ^7 w6 e7 e3 z4 _! z, i
MODULE_AUTHOR("Tronlong");
9 R/ e% N8 s3 i6 M" G3 p6 VMODULE_LICENSE("GPL");
9 _. q y" J ?; J
8 c& E& E2 j. m3 Y$ B: k |
|