|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) }8 G2 ^% v9 F7 k! G, J; C* a" }. U; N#include <linux/init.h>
# H: l& K$ G4 B! Y* k; }2 n#include <linux/module.h>
, a1 |5 s+ F7 Q$ T6 ?#include <linux/kernel.h>; A: N* [# O2 {. h" l
#include <linux/types.h>
8 X2 m* E3 O7 c2 ^. l#include <linux/gpio.h>+ |& q8 r: h# i3 S
#include <linux/leds.h>4 a, e% K3 w4 [$ f7 G
#include <linux/platform_device.h>/ @) c- ^' V1 Y! K
. c. r7 v6 z5 t7 y#include <asm/mach-types.h>
! c5 Y( Q$ e& \( P( P#include <asm/mach/arch.h> f' `. F# i2 {0 u& A
#include <mach/da8xx.h>% a( L0 \0 K6 R6 c9 Z
#include <mach/mux.h>0 l& G! `- q( j2 L; m3 \: M. Q
$ R. t7 k3 Z; A1 P L4 |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ T: v! J3 B$ O3 y' @- {3 q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) X0 R8 a" z) H! [# e3 V9 J$ N( @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 B& K, ~+ g: A6 n. ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 h& d/ j+ L) c8 k
6 Q) J6 |0 V* ~! q0 Z8 j/* assign the tl som board LED-GPIOs*/
7 f/ `& {& R+ Z; v. m4 bstatic const short da850_evm_tl_user_led_pins[] = {
! S! G' z* P9 j2 m /* These pins are definition at <mach/mux.h> file */1 _; u! |/ r8 c, j5 S+ d
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- q2 V# @: S0 b -1. A# h7 M- |7 T' ]1 f& u. F
};
' r2 }1 | A& m2 ]1 A) P9 ]( V
( a l" g, b+ v- fstatic struct gpio_led da850_evm_tl_leds[] = {. H" g8 G8 ?' I# | j: J1 z7 O
{
3 f$ z" t/ Y" B$ k! G5 C .active_low = 0, \7 U# `, c. L4 O2 x, r
.gpio = DA850_USER_LED0,3 ?' r: D5 A0 {* l" T+ _
.name = "user_led0"," e' p) P: i. R9 X; G0 ~. E
.default_trigger = "default-on",/ | O4 O! \# u" E+ l, e. `' H# Z
},* _+ e5 `: j" y) |0 s5 l8 L- |
{
2 g! v- ?* [& ?# }# b7 Q$ W: L .active_low = 0,
* r3 v/ @1 u1 c; k* { .gpio = DA850_USER_LED1," x! H. X0 G0 D% t" S1 l
.name = "user_led1",
7 D2 L7 v/ R7 S7 c, | .default_trigger = "default-on",4 [/ B L0 {9 ?
},
) Y p& Y. @3 |' ~ {0 x T3 t* T0 D% X1 k
.active_low = 0,
. x+ N( K2 s2 m/ Q .gpio = DA850_USER_LED2,* w+ r3 K n5 n9 n+ \3 y) h8 w
.name = "user_led2",
0 @' @* @0 T) M .default_trigger = "default-on",
. y1 r) |9 V( C; F z5 o; [ },
& k& a/ d0 G; N0 o% g7 W {
0 o! G2 a: E& Q8 P1 _ .active_low = 0,
% r% g" `8 w& D- A7 B .gpio = DA850_USER_LED3,: b" S1 u0 h) A2 u# q
.name = "user_led3",
, W+ |) |# ~2 X m: n& K .default_trigger = "default-on",
9 p: O6 u$ ^' o5 H) k+ b3 R s },
$ @. S( q* u5 u* f};
& \3 c# ~$ a3 E- A
6 J2 Q3 s' n% M0 I! i$ Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. F! n2 b' u+ J5 f .leds = da850_evm_tl_leds,
% E3 g# D8 C- D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: n3 U4 {( o) d0 `! _ q
};4 e" r- J) o$ T4 r8 S+ W
5 f5 S+ l, S6 x: f/ qstatic void led_dev_release(struct device *dev), Q7 |3 d( V3 P9 z
{
! U& Q+ d- `, m( S};& s) \) Z/ @8 _" W
1 h/ [) p9 r7 W* z$ P2 E9 X
static struct platform_device da850_evm_tl_leds_device = {. G* C& d3 N, x) J3 D9 h# z1 b6 ^
.name = "leds-gpio",
# z- ?. l* T$ [# h9 O .id = 1,/ ?7 e1 j9 \7 K0 ?
.dev = {" ~/ X+ Q( ~ g2 c' Q
.platform_data = &da850_evm_tl_leds_pdata,) n2 I6 Z& t8 W% H6 L
.release = led_dev_release,
( i8 u( `- |4 W l, e' b# q( k$ D }6 f5 p: v9 I! c8 \
};
: O* D* p1 x, T- R9 D9 j. P8 j+ q* v0 W
static int __init led_platform_init(void)
, ^- c& b8 Y3 J- \) `. V3 i* E{/ w: E" _1 |( h6 G; p" h# i
int ret;7 o- Y, \" f6 Q8 D' a4 [
#if 0. F9 z# d3 i/ V
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 f% p ~0 ?0 F# X# k& f if (ret)
- v! b8 f3 @. \! a/ f+ n( c3 f pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! J4 d$ ^, k2 k6 q
"%d\n", ret);6 X6 V3 Z. z) w2 l* W4 P8 [, z
#endif
. u3 W0 J: F( E ret = platform_device_register(&da850_evm_tl_leds_device);
4 }& O1 T) Z5 e. Y if (ret)
+ h' U5 W" |" ^/ V n0 g pr_warning("Could not register som GPIO expander LEDS");+ _. S) R% Z% v7 G; `5 s$ g+ w
else
0 F0 P2 \3 i0 l# f printk(KERN_INFO "LED register sucessful!\n");6 v- r1 M: @+ L
4 v5 X; A& n# y$ L# @% o: a
return ret;
# }% B9 I4 C( W}$ B2 |& h( V! U; W! m: j# [
/ u# V) g; F+ g) t3 C
static void __exit led_platform_exit(void); o" V5 A5 [% I \
{
# f9 }1 P/ O& g' s platform_device_unregister(&da850_evm_tl_leds_device);" r/ v2 `- |' C( F% }8 D8 Q" B2 e, d
1 R" C A) b* u
printk(KERN_INFO "LED unregister!\n");
6 b) V( [) l a}' j; u, P6 l9 n7 P5 E
5 O* Z" P3 E- \1 U+ b
module_init(led_platform_init);' a# F! j& x. h# J" ]0 p& h
module_exit(led_platform_exit);
, q1 s) B, \" e/ g" d. D
. T9 ~% k# M7 HMODULE_DESCRIPTION("Led platform driver");
6 H; D, Z4 }1 I7 [* W; SMODULE_AUTHOR("Tronlong");/ c$ B$ m/ ^) h' Y, q
MODULE_LICENSE("GPL");& q4 u9 v8 V( \# l: I
& ]1 _5 Z2 U/ A8 W7 V, g
|
|