|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 L4 F8 ~- e" F' ~0 [#include <linux/init.h>
8 P, c1 F$ y4 N& `7 U#include <linux/module.h>% \. d( U1 v0 t/ {+ v3 t( K) m
#include <linux/kernel.h>
3 a/ U( m- k: @0 S9 O7 [#include <linux/types.h>" A: d- X, i6 P4 ^* E S
#include <linux/gpio.h>
! r- K% G; \4 Q" E#include <linux/leds.h>
" s9 J' Q- E7 H#include <linux/platform_device.h>6 W* ^& \# j% W# H/ @4 |
0 T3 v; G5 |" u& c4 a4 R( j5 y/ s
#include <asm/mach-types.h>
2 Z% |5 W, J3 H% g6 |#include <asm/mach/arch.h>
$ Z& A; b3 D1 h# f#include <mach/da8xx.h>. D5 j# I; H2 Y0 \2 @
#include <mach/mux.h>
8 e- w- ]/ k! V& f% G `
$ m. w5 U& r1 k2 H8 m# d: R3 F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 S/ B; o5 j. K7 n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 l/ S5 ~6 `; s" N#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* i# r- B& R& }9 k: Q2 O: _: }7 W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 u' L$ R5 X8 I# Q1 ^
5 [+ e/ s, w) g& X/* assign the tl som board LED-GPIOs*/; D; f5 `) J n6 x O
static const short da850_evm_tl_user_led_pins[] = {
8 }2 I& y3 `. ` /* These pins are definition at <mach/mux.h> file */
- E& A6 P2 X2 Q5 _ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 K0 e1 ?! X; q1 v0 h
-1& Z( v" m8 l; \0 |( \
};/ N' U( r: D" X; G/ F
, X t4 J# F4 b/ p* K
static struct gpio_led da850_evm_tl_leds[] = {
8 s6 L# k! v- v$ E# Y( o( k {% l0 j2 p4 s/ v8 q
.active_low = 0,% w" f* `# g4 Y. Z9 z
.gpio = DA850_USER_LED0,3 G/ e6 Z6 H% o' Q
.name = "user_led0",5 ?; D; u/ P( q8 G L% h: F
.default_trigger = "default-on",! x$ b$ U% \$ ]7 B! S* k0 A
},
& ^, H0 v& u' I% p& A4 l {& p! _1 ^/ S4 x! y" p
.active_low = 0,% j o# w8 ?4 ~
.gpio = DA850_USER_LED1,
6 i* `4 @3 z3 M" I' B- ^- h .name = "user_led1",0 n% v2 u" a9 r7 B7 e( P% V
.default_trigger = "default-on",
# i2 g0 E- u- c( g' c },
# W, i$ l; ~4 J; M) ]2 a) d& |, j {
) _2 x% M" F; U P; k5 \2 Y4 h .active_low = 0,
a: @/ h. |) c2 e1 X" [ .gpio = DA850_USER_LED2,
- {/ ^! g. ?! _7 b$ A, J .name = "user_led2",
6 w, c7 m0 B, \8 D }. W6 [) o' @ .default_trigger = "default-on",
: `+ T- W" ?6 } m l },
5 Y9 g9 r2 ^7 q3 L0 X N {
$ u5 Q- V* N- o. ]# C .active_low = 0, \ W! _' s0 h* Y7 I, p$ }
.gpio = DA850_USER_LED3,
6 S9 K2 H5 @$ S4 h- u- A5 e .name = "user_led3",2 A) t+ `; Y! E3 {* U; c7 z' m( B( ^
.default_trigger = "default-on",
0 y4 Y4 F. h: {7 u& X },: z1 b) j* ~# d. d3 h" x& x
};* X; Q% q" v2 x
# E- m2 z! x7 ~7 @& ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: c/ |: V4 d- c6 D
.leds = da850_evm_tl_leds,# Q: C8 I9 i3 d! f
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 [8 y) p" O% Q0 f% k2 A
};
! d9 R" H5 S. q9 i) |' U" k2 w1 R: J' _; p7 N
static void led_dev_release(struct device *dev)+ j# y1 p0 F6 x0 S! c- T0 v
{/ t- N% n& `% r m& m: X
};; V U0 M& ^# \# A
4 d0 ^* \% W$ b9 @static struct platform_device da850_evm_tl_leds_device = {* \0 Q8 O' v- N+ [* h
.name = "leds-gpio",) n( `6 t" v& e/ S' \5 M% {' [
.id = 1,
6 l+ l6 _2 T* T) z+ l+ E/ |0 n .dev = {( Q5 A/ d4 T) k& M, E8 S& ?8 y
.platform_data = &da850_evm_tl_leds_pdata,/ q' `8 F8 Q, u' ?
.release = led_dev_release,
; d% n8 i$ e9 H/ I) c; P9 V1 f }
8 j0 B2 B! `$ |( S; ~};
1 ]8 O; s% w8 _2 {
% V3 U! M6 M# h! \static int __init led_platform_init(void)( t0 c& j6 b" f, I( M2 |
{5 N' _- W' n% q( [; Y" h; `
int ret;# k3 K3 W! x8 r5 C, q0 j
#if 0
& x& O H) \$ `9 n0 ~ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, a& \5 |' }; \& z! k5 k% g
if (ret)3 g; T- T+ `' S+ I7 o1 e
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 ?. M& }2 G$ G/ h/ A
"%d\n", ret);
! ~5 U: Y, L" [#endif
5 k) P2 `4 A7 @ ret = platform_device_register(&da850_evm_tl_leds_device);
. u4 ?# s1 A0 h if (ret)9 q/ e1 _! D3 E) R
pr_warning("Could not register som GPIO expander LEDS");
7 C2 j4 |! ^- w2 f9 t else
7 Y y& w7 y$ }: v/ h5 ~* ^+ Z- ?+ y printk(KERN_INFO "LED register sucessful!\n");
6 }+ }! [6 }; W9 `5 ^
3 _* b" e0 E6 J8 B! `# l return ret;) U6 m. C3 d% ~ J' i
}
, E/ m. [; } T9 f; C& R2 t' e8 Z1 }1 D- h6 v& g+ ~
static void __exit led_platform_exit(void)
+ I7 x$ ?2 [( I4 B0 s: G{
2 u. A5 }( c4 S$ @7 I" n platform_device_unregister(&da850_evm_tl_leds_device);" e& ?2 j+ D8 t9 ?
. R1 t; ?2 g$ Y
printk(KERN_INFO "LED unregister!\n");
) w% c6 ~# }1 Q1 y B}
{$ A: q' n( b
! E0 r# ]( }0 T8 Q- Dmodule_init(led_platform_init); G# L8 T/ j* y( t" h
module_exit(led_platform_exit);
0 k9 H6 F+ `- u% a( E9 L$ q( H( |. ]( h I
MODULE_DESCRIPTION("Led platform driver");0 s) n7 ]& P" c
MODULE_AUTHOR("Tronlong");( W4 l+ w. |- j2 m( _
MODULE_LICENSE("GPL");
3 _7 A, L; t5 n% q' }9 Z7 F- A1 p7 w9 y
1 V# v @+ S; d |
|