|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: H! p- E& W0 F4 N- _+ A4 d* \
#include <linux/init.h>
4 C$ M, h* O6 ?3 |2 T) ^#include <linux/module.h>. b6 H; u1 | Z# G2 ^
#include <linux/kernel.h>
' P: d4 M+ T U v4 S/ P2 N#include <linux/types.h>
+ E0 r, I2 ]9 z- @/ |#include <linux/gpio.h>
+ ~+ Q3 @ x( {; t+ I, |; Y& I6 O#include <linux/leds.h>" x2 x' i9 D1 D$ }! X- N8 J) x% a
#include <linux/platform_device.h>
) D3 q% ^( a% w3 m: s# g5 M3 Z& m" S, X" h! S" I7 ^5 g/ S
#include <asm/mach-types.h>
5 @& ~+ q/ E7 e/ I4 W# G#include <asm/mach/arch.h>2 h# b6 }5 ?' a7 e2 j3 b3 m/ V
#include <mach/da8xx.h># |7 H( N9 c& Z+ Q/ y' ?
#include <mach/mux.h>
9 W$ E/ ~8 \: h5 [, Q# R5 d
6 r& k; Q5 J6 D! m2 K$ ]#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 m* N* u5 v2 I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 j: H# K# x0 p4 o. t3 c6 ^2 N' K( X
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, H. Y4 P" K) n* D! M#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 P4 z. b% g' H, C/ N) o4 c% K. m) z, u- e0 f
/* assign the tl som board LED-GPIOs*/& @9 S1 G; J* q2 a5 f
static const short da850_evm_tl_user_led_pins[] = {/ [/ }3 i6 A% S3 e* M2 V
/* These pins are definition at <mach/mux.h> file */8 D6 }1 A) S8 P( M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: Y8 T2 k ~; [5 \9 L5 s: [$ G7 u -1 }1 G; [/ L: P( L) ~8 A$ C
};
" q2 r, g8 A! }, v" q' Q/ I6 f2 s- G
, V/ I; E9 p+ ^, [ O( S& c+ qstatic struct gpio_led da850_evm_tl_leds[] = {
$ y5 j9 a8 o: b& ?8 N0 d {3 \- C' U7 u5 A8 E; o: d9 B
.active_low = 0,
) w0 G, e, H8 w5 q2 y. j- E8 i .gpio = DA850_USER_LED0,* q" `0 i, } S8 S3 F3 N
.name = "user_led0"," G0 J6 H6 W* E( }' ?
.default_trigger = "default-on",# D9 |- b( `. p& p/ j! h. F
},
6 ^2 Z% c9 \5 @2 ^, }9 M4 i4 w {5 f3 |6 s& T0 n1 R( \4 |" J
.active_low = 0,$ J4 S7 F* h/ E y
.gpio = DA850_USER_LED1,' Y9 d3 h# l: R O7 b \7 r* S1 `
.name = "user_led1",
# \+ G& h1 y$ z' m5 n _3 r$ ?4 p .default_trigger = "default-on", A% t& q! @ Q3 ]' K
},
: \# r `8 L1 B" j& M {7 a% c9 K, i3 s; d5 M
.active_low = 0,! A$ U& V4 u& ^7 a
.gpio = DA850_USER_LED2,
8 l8 `$ r9 n5 N* o5 a2 I .name = "user_led2",
) X' a5 H5 @6 N' g .default_trigger = "default-on",8 Q, V" z5 H! s3 f8 K& {/ J
},6 M0 T' n/ G! d t
{
2 S" k1 \+ ?" I5 C! J$ i .active_low = 0,! e' c5 ?- I/ u/ e' |& ~
.gpio = DA850_USER_LED3,% E) ? X# Z% u2 |$ _$ V/ o
.name = "user_led3",6 h5 k4 Z# p/ w: r! @) ^8 ~
.default_trigger = "default-on",! c0 S' }0 D- P) o" R/ C4 \/ A
},
5 _ M0 I# G" o$ q8 N# O};
- t7 t) d% k$ ?3 I w/ \2 l7 h* K
' w" j5 ^8 @' j2 J5 n9 J* \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ A6 r' B8 K4 C
.leds = da850_evm_tl_leds,
0 e8 k, x4 c7 ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 e: H0 \1 W$ i: q* z};* l; t0 e( Y. I- D
) w1 j/ P, L/ g9 u* U# A
static void led_dev_release(struct device *dev)
# S, R0 B% V/ R6 a{' w1 h' Q$ Y) V7 z# {. p. C1 Q6 f
};
8 t* x( f |9 D7 {. _/ _
* y1 [/ ]. N8 l/ Cstatic struct platform_device da850_evm_tl_leds_device = {
8 I; v. {' H! z6 ~7 T; F/ e .name = "leds-gpio",
$ B3 Q9 X9 Y$ o0 E1 x% j* L) t .id = 1,! m Y( f4 e% ~$ C
.dev = {
1 c' Z8 n# U7 i6 S* ]( F( Y" m .platform_data = &da850_evm_tl_leds_pdata, [5 B0 t Y1 J
.release = led_dev_release,
( p" g8 Q7 D9 N, }4 a3 U }5 X/ J, f+ ?, Q! r) P
};* Q7 `# ?, B; p, a
* d( {$ c! l- |' @+ ~
static int __init led_platform_init(void)+ Y$ a d3 ^3 p8 I1 C3 N
{
4 F) h6 |2 X7 X) \2 h. s int ret;5 o1 N6 _5 D$ a" g% U' o- c$ F
#if 03 s4 T, |$ _$ M. Y, F$ i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. z0 |0 K5 C3 f, X u |! `2 L
if (ret)
% C% U. H- r4 W( Q pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% F2 L; B5 t% G8 Y6 J$ `
"%d\n", ret);' l! T: S, c3 \& ~# q+ Z
#endif
+ Y2 S: [/ ^2 C+ `( v, T ret = platform_device_register(&da850_evm_tl_leds_device);& ~) K: h# |/ f7 h2 r' m2 ?. E
if (ret)3 O9 W% M+ {7 C8 P, O1 T
pr_warning("Could not register som GPIO expander LEDS");
$ |9 R1 D9 o" c' _; j$ Q7 ^ else, j; _/ z! q- y1 Q
printk(KERN_INFO "LED register sucessful!\n");$ z% H# W( ~: s% G* F) u
1 k. n+ }; L6 Z6 `0 x9 Q* p$ p! V
return ret;
0 R, [+ j ~0 q n2 Q( U) v* }7 c}) @. |" y) z/ s1 @
3 Q! X& X/ t' w: h% L; A# T: q- z
static void __exit led_platform_exit(void)7 P0 r; m+ p& l! ?
{8 p D: m1 P# ~3 I
platform_device_unregister(&da850_evm_tl_leds_device);
4 A8 @7 C; p* A" U
0 R* p: A1 F9 | printk(KERN_INFO "LED unregister!\n");' F2 \ G: R) m* @
}
5 i1 n+ a) h" t; G8 c( r6 Q* U( S
module_init(led_platform_init);/ g" T# t6 ]1 u( V1 C& s; h
module_exit(led_platform_exit);% |- c" [/ @4 [, l1 M
( j8 @2 @, j8 g* v
MODULE_DESCRIPTION("Led platform driver");! ^ z' I" H* U( a7 F7 l
MODULE_AUTHOR("Tronlong"); |& [& J/ u f! [- ^8 t7 z
MODULE_LICENSE("GPL");0 I! o; n1 D. Y1 y. y
" X9 d8 L5 W+ q0 [7 L" H! p |
|