|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 x6 S" i% [+ i' E, K: ]/ U8 \! w
#include <linux/init.h>* v3 S' D9 {& z, t3 Y" X( f
#include <linux/module.h>
& x: T( p8 J. h T#include <linux/kernel.h>! ^( E6 }# b9 }9 D! _/ j2 Q% q
#include <linux/types.h>! g8 c4 P9 ~' E& C! b1 Q% y
#include <linux/gpio.h>6 M ]0 ~/ a$ }0 [) M
#include <linux/leds.h>; o, g* \$ i$ m
#include <linux/platform_device.h>1 e$ e) \ [8 Y# p% ] s% ^# O
I. u4 \& X6 c- X#include <asm/mach-types.h>' F) b! u5 }1 a
#include <asm/mach/arch.h>
. E, S$ O$ v8 \$ I8 N#include <mach/da8xx.h>
5 y3 S+ R# y. Q9 `! \8 T) @3 p#include <mach/mux.h>
1 p, b/ |, N3 I, d
. p# i5 \7 H% J# o$ X#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' l, ?0 D$ I) p! g( C) W3 R6 _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ L$ J! w0 l0 y# N, P) u
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# f1 k7 o2 v' M- m2 F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 \- T% j5 v- r0 {1 ]+ E
9 _! F! y6 T% c. `6 p* H
/* assign the tl som board LED-GPIOs*/
- h2 P& r5 G. pstatic const short da850_evm_tl_user_led_pins[] = {
+ |' M# X- g0 {- ?7 P- E6 D- f! { /* These pins are definition at <mach/mux.h> file */
9 w8 L0 s3 M( D m* a% H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
u6 g4 M: \! M6 C. ?3 l; y -1( l$ E+ O+ u! E' a4 A" n6 O" X) v
};
. y8 Z. B' I% |* e2 c! e& Z6 B; s- Q) D8 V1 q+ S ]
static struct gpio_led da850_evm_tl_leds[] = {
) `- O+ X" H) q! p: [* b {
! y1 D q9 A8 _/ f- ^ .active_low = 0,
+ M6 Z0 R, q: k+ c4 ` .gpio = DA850_USER_LED0,! Y5 L* k0 P, z, q% [" l
.name = "user_led0",4 L2 G3 c4 c: q; u
.default_trigger = "default-on",
' F: e- B' @; h; t },
2 U$ A# E+ @0 ^6 K+ ~+ } {/ W3 i. C8 y! ^3 Z
.active_low = 0,
( W! q+ W" _! N4 E( W .gpio = DA850_USER_LED1,
/ Z' T1 s5 t" N8 b .name = "user_led1",5 I7 i8 B% p( _2 k4 t0 x; E
.default_trigger = "default-on",
( _9 F2 f0 {- |) V },$ ~3 `8 d- K+ X- @7 `. E
{
) E6 C8 _4 z. W, B .active_low = 0,
; k' g2 l* D$ B .gpio = DA850_USER_LED2,, D5 i, n# W5 A* j
.name = "user_led2",$ A8 k7 @3 t$ B# b/ d
.default_trigger = "default-on",- a7 w; g9 l. p
},. Z* k/ C" x S7 L8 d
{
9 g" { @- e) s& a' f; o .active_low = 0,
0 l( y) M. t- h- T: k5 n .gpio = DA850_USER_LED3,3 y1 c3 _( Q1 U. ^& ~% j
.name = "user_led3",
& \* j9 v$ Q2 G( T .default_trigger = "default-on",) E3 q& R3 s" D0 E4 y
},
+ W" Z+ C4 k! v: C4 v$ x4 t. s};* O4 N+ c: w+ o! O& ~
+ S7 w) k/ w/ Y! A1 ?6 Q& t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' |- L! p# H3 V( m: _ .leds = da850_evm_tl_leds,
, e4 j3 P2 G& [ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 C5 s( p; V1 [. I ]: p( R
};: m' F, x0 b; d' K ~* W2 B; W
. O5 [4 x# j9 o" pstatic void led_dev_release(struct device *dev)
: |5 L9 M3 }2 b) I9 o- ]! h/ G{- _8 l3 Z( K0 J! D. c" k
};- w" u) }' y' r8 C, p
) X# @2 `/ l9 B d0 y* c- g
static struct platform_device da850_evm_tl_leds_device = {
. R4 i& R1 d$ M2 G .name = "leds-gpio",
3 P) d" }1 W& j7 x' ]* N .id = 1,
" h- m L/ m4 y. S .dev = {' p/ g. T# F" ?( T1 u3 e6 ~: x/ f8 x
.platform_data = &da850_evm_tl_leds_pdata,
. ^, {/ q: h, a! D, _- ^0 U .release = led_dev_release,
3 J% O+ V; R7 R% T }# q& f P5 u2 C9 g# K$ L% P
};
# K, g6 w s2 a3 H2 h6 Y1 Z
, @7 i9 C; e* i fstatic int __init led_platform_init(void)
4 u/ F! [$ Y6 k3 @ y" m{
" q* V; |+ n( @% P; z int ret;
* c, W# i" s& N4 b# C#if 01 J' Z. L' h; z7 \1 j
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 o2 {1 }! K$ P: u& W! {
if (ret). A0 ~9 M6 \. Q# u. l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 _4 i$ N! ?5 x* @$ I" m
"%d\n", ret);% U: `; X* {/ c/ R& |' _8 S
#endif ?6 W+ c9 ~( [9 |+ u+ ~/ k3 Z
ret = platform_device_register(&da850_evm_tl_leds_device); r* J1 P# Z5 \: |* u3 }9 k
if (ret)
, Y1 L' N C) F6 m }) T pr_warning("Could not register som GPIO expander LEDS");' c+ Z5 a# M+ q* J( x2 w2 X
else
! Q0 Q/ ?! l/ M/ P3 R: ^ printk(KERN_INFO "LED register sucessful!\n");
: i* g" m4 `5 C7 i: C
( {4 w+ T+ J9 |5 b return ret;
* i7 z/ V9 k G! l) z, [" y}# u" c" U# C$ f
$ k$ K. l5 n- P6 h& |
static void __exit led_platform_exit(void)7 |6 t4 O( U2 ]
{
( M: q* G! D1 I* z, Y platform_device_unregister(&da850_evm_tl_leds_device);
$ G- ~5 O4 |9 {$ [
- N1 R( i8 w5 |' G/ _ printk(KERN_INFO "LED unregister!\n");
* i( Z6 c. N4 o: d7 o1 A}$ ~4 m7 Y0 z+ ?$ t" I
7 x8 D# h! ]& j) ^module_init(led_platform_init);
% U: V7 f) v/ o7 Fmodule_exit(led_platform_exit);
' h+ b! h" s& {2 o7 Z
9 b2 u( C: n' q" Y; \6 p! a; Z+ [$ |MODULE_DESCRIPTION("Led platform driver");
3 z" g- h, P9 c l3 [' t9 h) YMODULE_AUTHOR("Tronlong");
m/ Q, p [/ p8 a! S) i: h+ y7 iMODULE_LICENSE("GPL");6 f# B" t. q! T' @$ {* j
4 @' A# I7 R' f: E( n: T3 ~8 k
|
|