|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 f* n/ w0 y# o0 u+ g/ R" r$ z#include <linux/init.h>
( S( z8 u0 ]: h% h& g0 s#include <linux/module.h>
4 @6 D; Y0 S5 X5 S1 G#include <linux/kernel.h>
" O* d. `9 I- b& h#include <linux/types.h>: c" u5 ?8 e" L" d$ u
#include <linux/gpio.h>, R! L( x* z$ y) t
#include <linux/leds.h>
$ M" a5 q' l* F" P8 p5 E1 a#include <linux/platform_device.h>
$ }4 x0 Z( ^, K0 f) G: u# _; e. u8 [6 R" k" i- M
#include <asm/mach-types.h>
) k1 V7 V( {, c8 O, b$ I2 o. u# {6 z#include <asm/mach/arch.h>9 g: K0 [% G0 E! w ~6 r; A( `
#include <mach/da8xx.h>+ w3 Z# T% L' @
#include <mach/mux.h>/ ^* a o0 Z) x: \
4 R4 }- l1 e, S: N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" H- A$ o' G$ I6 B4 A3 I" e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" I5 s* P+ I% L. w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 @9 H1 G. u( n3 i
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ ]* H- Q' g0 ^8 I# e5 l, I
, ^5 F" W& v! p# T' v. Q5 z: G/* assign the tl som board LED-GPIOs*/: z" w1 Q) q9 ]0 I4 O: h
static const short da850_evm_tl_user_led_pins[] = {# x' _# {0 u& E+ I# x/ D& \" K
/* These pins are definition at <mach/mux.h> file */5 S( u6 W: {& _) f) u4 b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. |! i) D% h% P+ E2 w+ w9 s6 P -1# E4 @$ H K. h+ D5 n
};/ z9 w: G2 `6 w; ?3 A ]
3 y5 d3 x" E4 K1 Q# f' ystatic struct gpio_led da850_evm_tl_leds[] = {: J$ D- k1 z: n& v$ i0 ~
{* q0 J% @6 I% W# }
.active_low = 0,8 L) M9 a2 R! \1 c+ _2 ^: E' r
.gpio = DA850_USER_LED0,
$ P9 M( G8 C8 p4 R9 c9 l .name = "user_led0",. v- Z8 K+ O$ }; T
.default_trigger = "default-on",
1 L) K+ H% E) I ]( F },
: e! b: s1 Q e5 S7 Z {
! y4 s1 E7 l+ j+ b- j$ x: J9 f .active_low = 0,3 g9 A# i1 w; N
.gpio = DA850_USER_LED1,
8 r5 s, L( }4 P" U% g7 \$ W: g .name = "user_led1",
4 ]* c3 P/ n% x1 | .default_trigger = "default-on",
4 [7 J8 G7 E9 W0 T/ | },
9 b$ I3 J/ R0 l% S7 e7 @ {
, }, Y8 o1 N; l2 Q3 v$ x .active_low = 0,
' K( @4 P- K @ .gpio = DA850_USER_LED2,% c+ |9 Y0 J3 i: }
.name = "user_led2"," f( i1 ?) t5 Z1 O
.default_trigger = "default-on",
/ J: b/ }+ a+ w },
' E" T; e$ m" ^% T/ H {
! \# o1 x- Z$ Z .active_low = 0,
: }% `+ i' i" {4 z# @1 @, ~# X .gpio = DA850_USER_LED3,
" [8 I$ ~ }4 q7 J3 z' y; o .name = "user_led3",% A7 s/ ^: y3 f, F( t0 O
.default_trigger = "default-on",
+ A! w/ ]# {2 h( x },
( _7 m" Y0 Y% F6 v) u( z7 M" B};( D# x" ~5 h$ @. c& v2 ~8 d0 e" u
+ a# r) T, @( m: Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; a! B2 u# Z P3 [6 f
.leds = da850_evm_tl_leds,3 x+ h5 V a* U: E
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 C8 B- A; Y9 E8 {6 q/ H
};
( Y! p- w' n5 J+ Z7 F) c a0 Q& G) W0 t% q# E2 d6 ^
static void led_dev_release(struct device *dev)( W$ \/ h `4 K( l. F0 @4 }
{
+ j( v+ B9 {/ f# r1 k};+ Y6 Y( s/ b- R' R
5 K1 e6 q# U1 f. B/ c
static struct platform_device da850_evm_tl_leds_device = {
4 |1 X. j& N) s/ G, n/ s .name = "leds-gpio",& x9 g" l& \- X5 Y; B0 H
.id = 1,$ { l7 z/ H3 d) W+ ~5 l! x
.dev = {
2 {) b: L( W$ p, L! s* O .platform_data = &da850_evm_tl_leds_pdata,1 m! _% Y$ D* u! Y
.release = led_dev_release,( v) ?* V+ y- s8 Y2 _! p: ?
}) ~2 W7 p5 @- k
};
* H, G; D/ i: Z0 d7 W3 Q* Q9 Y2 J0 d+ L6 a9 \ z5 h
static int __init led_platform_init(void)
3 |: O6 U+ _9 }- p{
' }. w- V- w \ int ret;
. `; T+ I" e1 z#if 0' \" R5 F' L ]& x) R* z5 ^ C4 w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. s$ S" v+ Y: j( a$ v3 M% `7 \7 | if (ret)
9 J. `' }! `: P8 p3 n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ d4 k8 y$ U4 D: t9 M& `
"%d\n", ret);- ]& E: H$ V# d% V3 O" h) o' n
#endif
7 m$ j' E( Q2 o: I( i- K4 p1 ? ret = platform_device_register(&da850_evm_tl_leds_device);3 p2 X0 j0 {1 D' u5 u
if (ret)
1 ]: F2 |* o \1 M) P2 _, ~ pr_warning("Could not register som GPIO expander LEDS");
1 I( v- Y' [+ P0 [9 q8 R else5 t7 }* A; ~2 P5 j) v" t
printk(KERN_INFO "LED register sucessful!\n");# Z$ p9 D: x* }8 W8 N- x
1 C2 A' i; ]) v return ret;. O- | _, E9 M; j+ r' ?
} w1 O! @: G0 W2 G
# r7 o7 L: v3 k, Kstatic void __exit led_platform_exit(void)# G2 U; F4 w# _ |5 y6 w* a
{& B, ^& O1 k+ B& D D
platform_device_unregister(&da850_evm_tl_leds_device);: H4 J6 ]5 ?! _- \, ^- Y: e' I
8 Z! n% c4 {# d printk(KERN_INFO "LED unregister!\n");0 _* g% u/ {3 M7 I1 Z+ F
}
/ V3 ?9 E; ]9 [$ I+ ^9 @4 |/ L
2 z. B4 R% N& c. I3 G3 l1 Imodule_init(led_platform_init);9 Z/ l [' U5 ]7 p$ I
module_exit(led_platform_exit);
* Z4 F/ l f& C7 e/ G* Y$ R {2 Q1 N) |8 ~
MODULE_DESCRIPTION("Led platform driver");
; t. Z" X0 b2 ]$ H s7 E* T' lMODULE_AUTHOR("Tronlong");, G8 @9 K, _8 \: `2 y/ O( P& ], R
MODULE_LICENSE("GPL");6 K8 ^% U8 t/ j
, l: M( P$ P7 o
|
|