|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
|2 }* a5 l: b$ O' R#include <linux/init.h>' V+ z& R8 l3 c4 v, q. ~
#include <linux/module.h>+ H0 V, ?5 \3 |8 F- k
#include <linux/kernel.h>
0 C- o1 Z! k# e' E#include <linux/types.h>8 Q7 x. ~" f9 M8 a
#include <linux/gpio.h>- }( o' }8 B" W( S- w% c
#include <linux/leds.h>9 ~( B; B. x% W/ u* _
#include <linux/platform_device.h>
9 c; @2 i, R) A8 w: f8 Y4 d/ s- J3 a& \9 `( b. O1 l1 t
#include <asm/mach-types.h>" ? w5 ~/ T+ F1 s, D3 x; V6 W
#include <asm/mach/arch.h>1 s* k! u, f: S4 B1 V0 U7 f
#include <mach/da8xx.h>; a! A+ @* `( N8 L' ~
#include <mach/mux.h>
% X! Y' B- @5 A; C3 x# Z3 X4 `
+ p* E, q7 Z! @- R& {+ m#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): \5 m( @$ }% n+ ~4 D7 X1 t' R* Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) x% T; K3 ^8 F6 `5 d
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 x- X( ]& j% r8 q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ h+ o: e' c3 X% M7 q" _
1 ~" u# N5 k1 M V- ]. y, t- i0 z; D1 N2 o/* assign the tl som board LED-GPIOs*/& x7 ^( \7 @1 K% Q# x
static const short da850_evm_tl_user_led_pins[] = {
. V% N2 {( S9 U, { /* These pins are definition at <mach/mux.h> file */
: o' X8 _7 V' j- p: j: z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 k( D' W( r" Q o% z3 s -1
8 F1 O8 G2 E' m2 V' \};
* N0 S: t$ o$ |( u! C
8 N& j: }" s8 [, e$ D1 |static struct gpio_led da850_evm_tl_leds[] = {/ t) }! G0 u* j
{
& h" H0 Z7 _- [7 W' h" ~ .active_low = 0,, z& y8 s+ ~7 {4 q& t' \0 @
.gpio = DA850_USER_LED0,
% x) O u3 o3 w' N' ?% \& w# l .name = "user_led0",
* g; y0 A3 x+ j, s4 i .default_trigger = "default-on",
I3 g2 D8 U& j7 e },: J; h! p% c4 H7 |4 B" Q
{
\' t: p& ]: i .active_low = 0,
r5 z* P2 ]+ ]0 s$ r .gpio = DA850_USER_LED1,( A2 \7 k: B4 v' Z3 o, Z% H
.name = "user_led1",% x+ M1 u8 f. R& u" |
.default_trigger = "default-on",4 x: p/ ?' v. l4 M4 w; o! O
},, W1 }& F% U, b% v' b8 W e
{
& d% b$ k, T A7 U .active_low = 0,
6 M+ k! u1 |' M+ G .gpio = DA850_USER_LED2,- ] z. e$ Y) K9 m# J7 j
.name = "user_led2",
Z. K& B* g9 i7 T .default_trigger = "default-on",* j+ G- o8 S' a$ u) Z
},
, Y$ U+ c- i- | { z C6 Y5 z* Y& C9 F& B, y
.active_low = 0,
* s2 {4 g* z( C& N" }, H0 ^5 B .gpio = DA850_USER_LED3,, W+ { F& t6 f3 o8 H" v0 ?; q
.name = "user_led3",
6 A8 ?0 N3 q+ E; H! l .default_trigger = "default-on",' H1 S8 `3 O4 [ D5 J
},
7 H7 ]: I$ S0 N+ Q& ~};, ^( a1 G! Y7 D r" J& |+ O
7 @$ ^1 ^0 r5 [$ y8 B- q* P- @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! H# H) j% a3 b$ s .leds = da850_evm_tl_leds," {3 F( O$ c1 ]. v% [
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ K4 i: o! F$ Z};& n7 S! K9 _7 j: N8 v) X
/ `7 m. [2 Q* Estatic void led_dev_release(struct device *dev). {- ^! U( m0 f* p. e Z& S) g
{( e2 O- X# \) ~2 ?
};
6 X) |4 ~6 k0 [) K6 t+ L, `; ~
1 l+ M# s! T) D# F$ x3 ostatic struct platform_device da850_evm_tl_leds_device = {3 b2 [8 I; P Q; }0 b& }
.name = "leds-gpio",3 l+ {/ ]7 _* v
.id = 1,0 y( | K0 c* H/ L1 n
.dev = {
# ?7 J3 Q+ t; ?9 z' Z7 c .platform_data = &da850_evm_tl_leds_pdata,1 X4 l5 o9 p8 h/ H8 X2 E
.release = led_dev_release,
m0 t! m3 F" t8 ? }
; Z( V6 W6 o( X N# x; G( K};+ R; `) f/ d b! A2 ]/ o
6 `& {- D4 a; K5 @static int __init led_platform_init(void)- u4 u1 q! F6 ?0 z! W! b. m
{
% y) y! Y# {0 a# f* N int ret;2 k w z' u9 r4 m
#if 0
! Y/ S) _/ d" a3 r ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; S+ ^8 T# P7 S if (ret)+ Z3 @4 o( b, L7 N9 [% P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ L" P* ]. b S' T7 C7 t0 l( _
"%d\n", ret);4 N, U# c5 Y5 Y5 G
#endif" s7 v( |/ q. A. u
ret = platform_device_register(&da850_evm_tl_leds_device);
* Y) K& i+ X$ V# p if (ret)6 K$ x/ l. y; ~! T% P
pr_warning("Could not register som GPIO expander LEDS");7 J. L, }& M& d C L0 ?
else, e# `. U6 g. [
printk(KERN_INFO "LED register sucessful!\n");$ F/ X( U2 S2 W5 A0 |9 t# f) g
4 C ?5 O% ^5 l- N
return ret;6 L6 X& |- r; S! p4 L$ y
}
: r. n9 B" `1 p R& l( ] B: Y/ D4 _+ o7 f& a
static void __exit led_platform_exit(void)
' _/ U! I2 ^' `. ]2 n{
+ P% O) E5 v8 A$ u platform_device_unregister(&da850_evm_tl_leds_device);/ I1 `9 T1 ~2 w1 i/ m9 g
+ U; d: |) V5 F* `+ k2 R printk(KERN_INFO "LED unregister!\n");! z* f* z! I ~- u9 v
}; |+ l0 d) G1 r' F* D4 F, }
0 Y R: x: Z0 o3 Q9 }9 emodule_init(led_platform_init);! k# n$ T- n9 r. p9 s# B- o6 b
module_exit(led_platform_exit);) Y# w' L# E# P) C) ]
. t0 }. R5 x8 {MODULE_DESCRIPTION("Led platform driver");
/ a5 c# A$ P9 X$ X0 g! l5 YMODULE_AUTHOR("Tronlong"); f/ f t5 |2 r/ k2 m! n
MODULE_LICENSE("GPL");3 m1 G1 t+ S8 ], V+ t5 u( E$ D
# I2 P I, G9 d }8 o4 @ |
|