|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" D f6 K4 N q- ~5 p. r
#include <linux/init.h>
6 Z9 z& X5 |7 Z" T! @#include <linux/module.h>1 H" s2 X; h/ |3 \: \: t5 L
#include <linux/kernel.h>2 F/ E" A2 f2 s
#include <linux/types.h>
' ^! {) l/ |3 d W' U* R0 A$ E#include <linux/gpio.h>
8 m- K' e5 G% `( B. b8 u( ]#include <linux/leds.h>
% G/ M, I m+ Z#include <linux/platform_device.h> r" x6 P( T: z# u4 o/ X
* J, q [% r% G" q" I z#include <asm/mach-types.h>3 }0 Y" v, L5 m+ E. T
#include <asm/mach/arch.h>6 _7 o3 p2 u6 w% `0 W
#include <mach/da8xx.h>6 y7 y" b- E8 h; ~! _4 s
#include <mach/mux.h>
& c, }( l* h# W. F& W: ]1 i' }1 t+ N9 j y$ s& I6 e7 U9 V
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! `9 f! h# p" R. t2 l
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( k. {; b) D$ d1 b- w0 K#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- Q( b: U9 D$ J* H8 b1 N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 f5 e0 }& \/ D5 C
, m. T- V' ~. {/ I. P
/* assign the tl som board LED-GPIOs*/& U3 @% I, f5 d/ ~& n3 g! W$ v
static const short da850_evm_tl_user_led_pins[] = {1 s$ g* F( t6 _4 ^& P2 ~5 D- j$ E
/* These pins are definition at <mach/mux.h> file */ k1 r9 }4 V3 G8 m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# \3 L5 v8 v5 l; g* H8 J
-1
) [& T7 {. d, a1 H: g}; x& N+ W, s4 f
+ }" m. o2 w, y; Rstatic struct gpio_led da850_evm_tl_leds[] = {
' V. N& z' t/ y9 ^" B. [ {& w1 Q* V9 d( `; ^' C% c! W
.active_low = 0,
, |* H8 {* o! Z. k2 H6 X0 E) o. c .gpio = DA850_USER_LED0,' ^2 s/ @+ o& R
.name = "user_led0",2 s* U8 K$ f/ O' L! t
.default_trigger = "default-on",/ d# c) \3 x' a
},, N- u6 X0 G5 C# i
{
) X4 y; i) a5 E% m" }+ M/ | .active_low = 0,) m& e% K4 D t* R0 S
.gpio = DA850_USER_LED1,
2 K" i; S4 t; c7 c2 [ _ .name = "user_led1",
( C& V/ z# b; I5 }" X7 B" p* O .default_trigger = "default-on",
' {3 z, g: {3 |; M# B },
* Z1 }) i" O% [7 ~) M {, a5 Y1 \' s5 O( |
.active_low = 0,! [! [: D/ R% j$ ^% N0 _" {
.gpio = DA850_USER_LED2,9 w; W v! @2 ]1 j# }2 i
.name = "user_led2",
8 J/ f, A% _% m/ V1 d, q3 T* ? .default_trigger = "default-on",+ b* P) p5 M D9 y
},' O( g/ S' e. N
{
% s* P3 j3 a& H1 R0 u5 n .active_low = 0,5 x& z; e* G7 F
.gpio = DA850_USER_LED3,
6 i2 k! z3 p/ Y .name = "user_led3",/ C: ~. d1 z' h- d. r. j. e
.default_trigger = "default-on",
" y: i& S/ s! Q1 Q1 @; b },+ \' p1 P% @$ R, c1 N6 t9 m$ H0 ~3 }
};
+ |1 c, w7 u! p1 P0 ` u9 m9 [! f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 @9 j E+ K I .leds = da850_evm_tl_leds,0 Z( `2 n- r/ A p
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ J, u3 L. x6 ^};: B! Z/ n1 n. N( [$ X# C8 z
! n$ P0 r) l2 v7 c6 h3 Qstatic void led_dev_release(struct device *dev)8 j% i' K' C& ]4 b
{# p/ |1 W u+ W0 R
};
+ l, s+ z# G7 V$ U
" ~9 o' ~* Z# R! x' \- G: P. ?$ lstatic struct platform_device da850_evm_tl_leds_device = {
7 f- a0 J: h+ i' y .name = "leds-gpio", ]6 E& G# F4 z& `
.id = 1,+ L% J I2 C6 i5 ^. e
.dev = {/ w P" K: I# X- X& |
.platform_data = &da850_evm_tl_leds_pdata,
. r/ H: M- P& b% x) _ .release = led_dev_release,
4 _( K; m( c5 a: I, t }2 X7 n/ g" N; ?: {, V' u' \
};
2 I# P+ L/ M. W: Q, v2 c
7 W9 Y" T8 [3 Jstatic int __init led_platform_init(void), K# O: z9 Q) T" [- K* l* }6 r
{
& ^- \) ?- N: h9 E; E2 c; E9 E int ret;# j) } O* c5 H, h+ u, t
#if 02 }! n' ]3 W: `
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' G3 k- _* u. c, N4 p2 I
if (ret)3 F3 [. A" Q0 E* A5 x
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* f* S1 }. b$ ]( B5 j- H "%d\n", ret);
9 h0 M& G2 }9 m#endif
# l2 v4 t1 b0 E: @ ret = platform_device_register(&da850_evm_tl_leds_device);0 \% {- Y1 i5 ]7 M- P6 Q
if (ret)6 l; q% i. h# v3 U& N
pr_warning("Could not register som GPIO expander LEDS");
6 ?8 h; c2 e- [2 _* d7 i else" K5 B9 |& h4 L
printk(KERN_INFO "LED register sucessful!\n"); H2 h x! R4 z0 L4 m
1 @8 I: I( ^! F
return ret;/ u7 J" f. a( q; T6 P
}
& ]: ]! J$ ~2 j5 ?& j
+ w0 W, W& S3 rstatic void __exit led_platform_exit(void)
+ d# ~: d3 s! U1 k: i+ C, T{- P( _; [& c$ `, L: H T
platform_device_unregister(&da850_evm_tl_leds_device);! [" W: f5 ]3 N* w2 U5 H! C
1 C' J7 F0 o; x. A0 S( V5 P# Q) A( x- Q
printk(KERN_INFO "LED unregister!\n");
, l- b W3 B( ~/ C4 S}; m* O* R& b0 Y" b
5 {/ M( Q; u' _' t" b$ P: Ymodule_init(led_platform_init);
3 s6 H+ P6 _1 wmodule_exit(led_platform_exit);
7 w) q" ]% j( i8 ~3 y& r' R9 l( E+ j3 q; d" h$ a
MODULE_DESCRIPTION("Led platform driver");6 g, h1 G) w4 E& Q) o9 X, K
MODULE_AUTHOR("Tronlong");
7 H5 \; w& J. i1 t' u5 D/ Z5 _; UMODULE_LICENSE("GPL");* f, y4 d/ Q% h1 j6 V3 U9 ^
# j6 G8 o( ]5 n |
|