|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ b$ V! M" r5 j) T
#include <linux/init.h>7 m1 A# E# K2 L5 ^
#include <linux/module.h>* N& {3 y' D3 J* @1 P! o
#include <linux/kernel.h>3 Z5 s8 ~3 S! u3 ~3 [+ y
#include <linux/types.h>3 L8 R1 I- ^# B# C5 z
#include <linux/gpio.h>& d* z; w% J0 t/ ^4 c
#include <linux/leds.h>
. D4 n3 l! |, [# J#include <linux/platform_device.h>
: L' s1 u4 J; _3 \* g
# o/ b& z, W% A( f% o& @* l9 @#include <asm/mach-types.h>/ V; A& ~) X5 p
#include <asm/mach/arch.h>$ @1 K( [4 S* g/ X0 c( p
#include <mach/da8xx.h>/ u$ @, x" i p% L+ c" n
#include <mach/mux.h>" Q! _' L; R+ c2 q( |7 [* o
/ l+ l7 d4 f+ [& L. ~& {9 p
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# d" R9 W( v" W6 E: r0 y* e% u; @0 d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! F% I* ?/ m* X/ i; f3 q( M+ `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 t) J* Z* W9 D" Q! V, s$ f/ W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 E; M0 D7 n3 S* M/ o& i( ~" L5 x; O
/* assign the tl som board LED-GPIOs*/
. S+ Y0 o* A0 Rstatic const short da850_evm_tl_user_led_pins[] = {
- h( w' K: L$ M5 d! @4 N /* These pins are definition at <mach/mux.h> file */6 u- Y7 `6 G: x2 k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' H& q8 x2 ]/ \2 d0 L( w @( J
-1
% y! n7 ?" x- \6 F};) D6 a: ^6 G$ a% {) a+ K# a
1 O& |" t) l9 Kstatic struct gpio_led da850_evm_tl_leds[] = {- ~; s+ L1 ?8 M& |: i( T$ c9 k
{+ m; v R/ t' c% S
.active_low = 0,
8 l1 [; ~' W# Q: ^7 b .gpio = DA850_USER_LED0,8 P% |9 G' q7 K% U; V( _; v
.name = "user_led0",
+ Q a4 x9 s: K) N" b0 X5 \& B .default_trigger = "default-on",
% m1 }1 C. L" I# x7 ^: A. ^ },
& t! l G: S9 M {
* u5 A) ^( [) b! w2 m .active_low = 0,
( `: K4 V% ^6 g, @+ @1 | .gpio = DA850_USER_LED1,) D1 Z( `/ |$ Q8 a- f+ z' ^ i% Z
.name = "user_led1",9 [4 |. z5 m$ v' |: F g& T, o& M# h# t
.default_trigger = "default-on",/ b j+ S' P# y3 D1 `9 t: ^4 A- N
},
p' D$ e4 D& W+ L+ J" q {
1 S" h( n8 L6 [5 p9 k5 @ .active_low = 0,
( Y" |8 Q0 a; i; a .gpio = DA850_USER_LED2,
( J# j. z& L) J! O# p1 z .name = "user_led2",( q( l, n* P! q& o; K% \9 B2 ]9 r
.default_trigger = "default-on",6 }: s+ D0 l; D+ v) R
},0 R# G1 r( Q2 B% e* S
{
* O% D, T* g: i9 V .active_low = 0,9 ^7 D9 K! @( x3 j1 t9 H' }
.gpio = DA850_USER_LED3,
, T% q8 m4 i }# F3 x# p, \ .name = "user_led3",$ Y: H X+ d- v* l7 O
.default_trigger = "default-on",' I. |% H+ p- ?. Q2 A
},
1 S; P6 B x1 v; a m: }: w; e};
+ |4 H( m7 G, ?# h! y
: e' {% \# k* I3 D, I. R* A2 X3 U6 ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: C+ B( [ h1 e5 ?7 N& L .leds = da850_evm_tl_leds,+ r7 G4 G0 ~) s2 t4 t% f0 B% G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 q+ ~1 G3 Z# z% U6 w c' `
};
9 l/ Q5 l1 L% N' p! J( R
8 b5 z. j& @3 C6 G }1 I7 z/ `static void led_dev_release(struct device *dev)
% e: j! n) Q: Z& [! E' h1 F{
& \* s, g8 T; w; a6 R! ]};7 X [8 t2 V% w6 b
; o' k+ V3 D# G% R
static struct platform_device da850_evm_tl_leds_device = {
- l+ z# U. \: ?: w) j# [/ T .name = "leds-gpio",
% f( k7 N3 a4 r7 r! E9 \. o4 z .id = 1,
& }5 \& L1 a& r4 w5 t* c% k5 z( P .dev = {! ~ I$ a1 k0 R: m* g, [. k
.platform_data = &da850_evm_tl_leds_pdata,
2 E3 c. h- R$ G2 J& q9 f# S2 ]" i5 u .release = led_dev_release,# c; Y" S1 I5 U( B5 Z! _& }9 b
}2 G5 x8 D# T) }" W B' p$ M
};
1 `! c. y' X! f1 @( A" k9 U( q0 n# z0 ^: V% |+ m
static int __init led_platform_init(void)$ ~2 z: m( }" z0 s5 D2 w- r. T
{# z9 L0 y" t$ J! `; P
int ret;/ ?0 ^1 l q1 Q# T; Y4 C2 q
#if 0
$ U6 R: @ N! _ f8 Q" v6 P ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. W' h7 r7 q/ d; N2 ?# l+ D
if (ret)& |; G' U, b n/ h' S
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" U6 V2 _$ \$ _# L# i* l! o
"%d\n", ret);$ y a( B" J; N7 i! `
#endif" @! @, x8 a" f# N, ^: v% o
ret = platform_device_register(&da850_evm_tl_leds_device);
9 i8 d/ ]2 S- Q if (ret)
8 [7 D8 N% O1 p4 U$ I pr_warning("Could not register som GPIO expander LEDS");4 U* c' \" T5 e
else
1 M; k8 S, f4 e# ^6 i/ P/ _) C printk(KERN_INFO "LED register sucessful!\n"); a w5 x+ G- z
1 r5 M$ ` l0 q4 ]+ I2 a$ [ return ret;( l( i# P o, {
}
+ a/ b) K8 F) S- r1 I
& `6 S4 B, P+ D) _, C @' Mstatic void __exit led_platform_exit(void)$ I& v: w1 c5 S. c7 X' a+ ]
{
) }; _5 U3 R e$ D8 ^+ K platform_device_unregister(&da850_evm_tl_leds_device);) d ~+ ~, e) C5 G
9 T; f* a' F2 `2 D+ M
printk(KERN_INFO "LED unregister!\n");
1 N' i2 x- B2 X% b}
) \) r7 D2 y& D) F, Z, M& r
9 e+ q9 J: r9 }( F1 m3 S) Wmodule_init(led_platform_init);
+ @5 L7 n* A/ O2 B5 X' D3 X) t5 umodule_exit(led_platform_exit);
/ `* ]% H% W( F4 w
$ |2 ], a- e$ aMODULE_DESCRIPTION("Led platform driver");
9 u; _ q. U% N7 T% {" AMODULE_AUTHOR("Tronlong");2 Q8 F/ d! \' S; E* Y- S4 d
MODULE_LICENSE("GPL");7 @/ L+ I# u& O7 _9 M7 v1 Y
% I2 X c( l" [+ l( w
|
|