|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) }0 ^1 N2 @4 E, x( ]7 X) A2 A& Y
#include <linux/init.h>
5 N6 X+ P1 J* |; T9 p#include <linux/module.h>
1 l, u: L: F' z#include <linux/kernel.h>5 o* s0 L8 T# S& v+ P% o/ [
#include <linux/types.h> m3 d+ P5 D- N
#include <linux/gpio.h>( |+ H/ m5 }3 Y* u+ n2 X- ^$ `
#include <linux/leds.h># h' w8 k2 X0 d: ?' z" P
#include <linux/platform_device.h>
, b2 t2 O& Q$ f( U2 |2 k9 J! K0 U$ A. T3 D; |7 c9 r& a
#include <asm/mach-types.h>0 x* [/ P+ \1 i' G' U: N2 C" R0 U
#include <asm/mach/arch.h>
# u) H3 D% ?* y) r#include <mach/da8xx.h>
0 W- Q6 c* q% {/ P6 L5 w5 O4 z#include <mach/mux.h>8 } o% r2 h$ o! E! [2 }* E# t
- o# H. u4 A& [: \3 G T
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ u6 ~# t9 W; g$ y# n* \#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 S: x' K4 f. X: h' \9 ~* P. M* c
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! W& P" u% p) I# G* t#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 ]0 `( E. `/ _! Z. _! v3 E, {0 i' T
! ?! B. y v2 x1 k, d; q/* assign the tl som board LED-GPIOs*/6 \0 h' M: P \
static const short da850_evm_tl_user_led_pins[] = {7 \8 h4 f; e# T5 F5 y# E
/* These pins are definition at <mach/mux.h> file */
2 O( p5 v) u; n$ j DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ y3 j1 @: p3 `8 o -1
6 h {2 p3 K$ y& `0 j/ F1 B$ L- u};
$ G% Q; H/ s) j) ?( `5 o! s2 B- M0 K/ Z
static struct gpio_led da850_evm_tl_leds[] = {+ s5 h5 U7 p1 Z3 @+ n j+ ]
{
# M& v. I G2 d* k. }/ C9 X' l6 E: T .active_low = 0,
% E0 O0 X$ `. _8 _ .gpio = DA850_USER_LED0,
! e2 a& v3 e1 i .name = "user_led0",
( x) z; O& }; \) L .default_trigger = "default-on",
2 [) h8 h/ f, x9 O9 y: M },
. z- ^+ W2 L4 C3 w1 M2 b7 |4 U4 f {
7 ~2 e1 }5 z8 Z .active_low = 0,* q/ _0 n) C- n
.gpio = DA850_USER_LED1,
8 {! f+ `& U. C! @6 H! z2 W .name = "user_led1"," J3 K" r9 x3 Z9 w
.default_trigger = "default-on",2 G9 h5 Y6 Z& f- \
},
/ Q0 j/ m, v9 E7 D/ G6 u. S {! \( S: Q7 ?4 w' _4 i+ |/ S
.active_low = 0,
8 g; G ?7 Y' {7 K5 A; ]2 a: G/ e' | .gpio = DA850_USER_LED2,
' R7 {, i% P, e2 G6 F .name = "user_led2",/ b2 C- M7 ?/ T! r, Y
.default_trigger = "default-on",3 @! Y" ]$ L# i7 o; M) i8 ^
},
2 j# A' b% G4 B8 T- Y L {
1 m4 O9 z4 Q/ b) ^9 `- A! s3 @- l* J .active_low = 0,
/ j. _( _1 r# G! u0 D .gpio = DA850_USER_LED3,
/ V) \% B6 ?, ~5 x# S0 I" c .name = "user_led3",* J+ M1 |) K; r) x3 e$ f: a) E
.default_trigger = "default-on",
" O) |) y2 |5 } },
: X1 V% _- Q- F2 a};
: U5 i3 k! t; e% I6 _$ ?1 M7 Q! E. M% U9 `- ~7 D5 f* |! P' H. ?+ S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- n. H& t" z1 ^# e7 w6 } .leds = da850_evm_tl_leds,
! d5 U/ [& E* b; `7 v: { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 _' T& |3 U2 P};: R7 I8 ?5 _- q3 I Q) j
3 N* O# T# h" b7 P" }$ f; Y8 O1 _0 U
static void led_dev_release(struct device *dev)
- S/ ^# o. l" Y1 Z I6 K{
) v+ t* n/ s* G% G8 D- D% p- p};
6 R- F8 g- X b* U& q9 f
; R; \/ G' s" E+ P1 A% }3 T2 |static struct platform_device da850_evm_tl_leds_device = {
! s7 [! h* | u6 Q0 g .name = "leds-gpio",3 b+ O; |" _- V% O1 Z# A3 \
.id = 1,8 B0 p% i1 [/ [1 y7 m/ a
.dev = {" K. y; u$ I0 j' } a; H) y
.platform_data = &da850_evm_tl_leds_pdata,
# G# T" `0 j; n% C .release = led_dev_release,# R8 p. v2 ~' q1 L& h) h/ h$ P! z
}
" w7 G0 _) O' j6 N2 f& O5 M+ u};6 c; Q# c6 W* c1 o
8 Y3 P2 y P1 V% s
static int __init led_platform_init(void)# ?6 [5 k2 V# E4 q, w; s9 o8 P
{! y6 |" [4 ?- y/ z
int ret;
+ K# x0 W8 h9 m" J$ U#if 0, C% I; H7 p/ f% r* M) _
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 }: E4 U: ?9 u& L3 u9 W
if (ret). H+ L5 f; ~7 u/ p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :". X" v/ M t# P/ p) ]
"%d\n", ret);
$ N3 o! P! |! @* |#endif
1 V9 F( q0 k, E7 L& [' i ret = platform_device_register(&da850_evm_tl_leds_device);0 P' ^4 e' g$ ` c* t
if (ret)
! L$ w! U3 O; t7 a4 B: M pr_warning("Could not register som GPIO expander LEDS");
, J; f4 B `0 h) z5 \1 c else
) P b3 @5 E% Y0 p z5 s printk(KERN_INFO "LED register sucessful!\n");
, g* q Z E6 u* v) b
% D- K- m1 J' ]0 h return ret;
' N5 [. S2 ^4 Y. D6 j2 _}) [0 g+ U3 Q" M0 C. H; N% k* g* n
) a9 H2 F- ^2 h
static void __exit led_platform_exit(void)1 H; c% R8 b/ f4 ?+ _3 U% G3 `1 [
{
' D' V# Y8 ~" R8 L4 b platform_device_unregister(&da850_evm_tl_leds_device);- T, G$ o! o, ~3 c, @
! Y0 l0 O- [/ g" Y* J( u
printk(KERN_INFO "LED unregister!\n");
- a5 L7 \( D, j& @. |' l/ o}: a- [% q0 E, w3 h7 I! K7 K& @: e
; ?0 }7 z: G/ B! U) [
module_init(led_platform_init);3 S8 m- T" t" _' [ p5 N
module_exit(led_platform_exit);( V+ m* Z4 B* R
6 u: v# G5 j0 M' j
MODULE_DESCRIPTION("Led platform driver");0 a! S: V, l) E% x0 y5 I4 z# V
MODULE_AUTHOR("Tronlong");( x8 ?8 X5 P' S, I) h
MODULE_LICENSE("GPL");
$ U9 D( W0 z% p6 n$ b' ^. B5 V4 y
" b/ }$ x' E/ ~ Y" U& _ |
|