|
求大神给下面的程序做注解,请稍详细些,谢谢。% d! l" N+ M1 q8 K- L
#include <linux/init.h>
* Z8 q% v. i6 H# v5 K# n) v#include <linux/module.h>. x; B, t* u6 R; D
#include <linux/kernel.h>1 l* K2 D/ E8 N9 j) h8 `
#include <linux/types.h>
3 J1 [+ W$ W# N#include <linux/gpio.h>
8 G0 @" |. _4 z9 U4 h& z#include <linux/leds.h>$ ~, a3 `' p- m0 [8 }# f
#include <linux/platform_device.h>
6 u; j3 ~$ ?, O$ i Z/ Z, e! L% c) ]* h4 }
#include <asm/mach-types.h>
+ ]2 J# R' K* g. O- h#include <asm/mach/arch.h>
1 J# K! h3 z t6 S, @" |8 R#include <mach/da8xx.h>
$ S7 e. W6 m* c. J, Y& u8 d/ b4 J#include <mach/mux.h>5 R; D- m: j' x. ^
$ H& a, Z% J0 b: o
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! |' F; ]% c( |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 }& F" d0 }: M: g% L( r$ S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ `; s" \6 S- ~9 l#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) |( t3 F5 u1 u8 z: K% \8 b
- M, x* N0 ~2 ~7 f: c) {: d
/* assign the tl som board LED-GPIOs*/; ^* c: b/ F# n* n5 ]0 ~9 |0 t
static const short da850_evm_tl_user_led_pins[] = {
& P" ^7 X. W4 C /* These pins are definition at <mach/mux.h> file */+ A& R9 D3 n/ e# x# V/ B
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ R- l$ j' y0 H( }" f" T! h# m6 ]
-1
# E5 w: d0 h5 E& _; q* ~};
! L8 u) i( ]! \! E$ D- x" A
0 W% l% G* ~" ?, [: gstatic struct gpio_led da850_evm_tl_leds[] = {8 s0 U! S( }3 n6 z: ^8 f
{. |- {' a3 Q) o* H
.active_low = 0,
) l- `, o* B! D .gpio = DA850_USER_LED0,/ e1 v% {% E3 _2 n2 f0 _; w
.name = "user_led0",
8 B! J! u( ] q- y$ T .default_trigger = "default-on",/ p# f6 @8 e+ L$ ]. e# h) z4 j
},! N, \0 n$ I! C% A' } i
{
) D. l; F4 K/ D .active_low = 0,
" r; ^) Z7 s% ~7 _! y .gpio = DA850_USER_LED1,; } f% a+ L& N3 w7 i, e
.name = "user_led1",( V9 O8 D) \* H$ M! N% L2 @
.default_trigger = "default-on",
5 x$ t( M' {- q, m' F },2 K% `7 l' l- T1 l. r
{
9 J: ?" A3 m) H( G; u .active_low = 0,
; p& E! T; M+ Q) |+ [5 _* o- c .gpio = DA850_USER_LED2,
/ V$ [( Q1 P3 o+ z+ |7 p .name = "user_led2",
9 w0 S" j4 _ ^+ A) H .default_trigger = "default-on",: W/ z$ q6 W( w( @1 W+ F% O0 J
},0 x* p8 P2 Q9 O
{3 n+ \! K6 b3 a( H$ d
.active_low = 0,) w; _3 Z& u. L9 o, `
.gpio = DA850_USER_LED3,! w, Y h+ i" \0 w
.name = "user_led3",% u( g4 ]5 v, l
.default_trigger = "default-on",- h' M- v o' {5 R% E; ` W# {9 f
},
4 \5 u" [4 a, f};: x+ ^9 m8 T, i2 m6 |
" C. I, G+ W( C& g: _3 T" fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) r( @ T$ m: d
.leds = da850_evm_tl_leds,
2 P. k0 K$ s$ e( |1 W. e .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 i: h0 `( w6 {- t};
+ ^' H5 }1 r+ X2 q
& l: D9 C6 M6 n: Z8 K" w' z' {static void led_dev_release(struct device *dev)- u- v% T2 O) Y) K* x( v
{+ I, W B9 Z9 C( B. e3 e4 I
};
. A) ]: \ m" R$ g$ J; Z
: l" ~! `+ I7 D( g9 Tstatic struct platform_device da850_evm_tl_leds_device = {
' W& ], ^# G0 ? .name = "leds-gpio",! q2 k Q8 b, O+ v9 J; [1 H
.id = 1,
8 F% T* K7 d' g$ O+ D' h4 p .dev = {
$ N. O: |7 Q& l. y* v .platform_data = &da850_evm_tl_leds_pdata,
e4 U8 y7 }! G2 a& l. o .release = led_dev_release,
9 Q, t- q' M' k) M( J1 f }
6 W4 n& e8 Q0 U D) C};6 d( P& {/ s" [7 C
5 {% A9 c9 k U* F+ Z/ z
static int __init led_platform_init(void), a; k$ N7 ^6 z2 ?
{' I% ~" p" G' V7 u7 }
int ret;; A( {+ r" i- ^- E% d/ d
#if 0
. s4 w1 I9 i3 u* K, I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 N8 i4 j P$ I/ |$ Z3 M. a# g if (ret)
1 Y# O8 y5 E! ?9 U. S3 n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 w3 k- y, N5 p5 [+ \
"%d\n", ret);4 b3 j2 w5 s) y4 {) n D
#endif
7 U) f: H) v( ]" |" ]& U7 } ret = platform_device_register(&da850_evm_tl_leds_device);/ l5 \7 K/ v: y, Z
if (ret)0 x( w+ U. E8 c3 s0 s
pr_warning("Could not register som GPIO expander LEDS");
: u' Z7 T8 N/ \( ~) T. ? else0 E6 g& t* `/ s9 L3 A* Y' y# H
printk(KERN_INFO "LED register sucessful!\n");% {7 V$ E* Z6 D
: p0 N2 `+ b/ ?( z6 \3 A return ret;
1 m Q+ }$ }. N}4 A+ X. S7 s% A2 j
# x. U- w6 C* }& y
static void __exit led_platform_exit(void)! u/ K0 Z0 F$ r# `' a' X' d7 L
{# B$ ?% q! b- J
platform_device_unregister(&da850_evm_tl_leds_device);
( p" ]* r, O9 t+ a7 Q" K3 W# H$ R
printk(KERN_INFO "LED unregister!\n");
) A) H. v& `' X% F% J- p2 U7 ?}
8 ^& p8 h; k \3 e& {; r4 D$ y8 U" q' y! w7 k; I; L2 H3 I; |4 F- h8 `% k" i
module_init(led_platform_init);
$ _) P9 _0 X" K4 smodule_exit(led_platform_exit);5 w0 o! A, a+ ~6 a: G
. K* g* E( F* f' u6 x7 |7 h
MODULE_DESCRIPTION("Led platform driver");
9 n0 `+ Y1 l; g: Z5 P5 e; X/ kMODULE_AUTHOR("Tronlong");6 h6 D# K1 T0 f/ q) W- C: h4 ~' {: ]
MODULE_LICENSE("GPL");2 r6 R8 t$ }9 w! Y- ]
2 w* r" `2 T, p& o
|
|