|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; \& H k) c. ^#include <linux/init.h>
) M: Q( I, |, h7 T% k4 I% H# v( @#include <linux/module.h>
! U% ?$ C8 c. j, E" C#include <linux/kernel.h>
5 D2 N. [& j2 L1 x#include <linux/types.h>
" z- s6 I% }! B! q5 }/ I2 X#include <linux/gpio.h>: W8 S0 J. N% ^/ V4 C/ n
#include <linux/leds.h>
1 D) A! U) z Y7 B4 e6 C2 L# R#include <linux/platform_device.h>9 [1 z9 n, }( n7 X- i9 A
" D9 {- Z" x8 W* x5 S4 }
#include <asm/mach-types.h>
* ~' v0 W) Y2 V#include <asm/mach/arch.h>
6 I8 `; N3 X' A* K9 I#include <mach/da8xx.h>7 d8 t! g, U& u" _$ F0 E0 u4 g
#include <mach/mux.h>4 L! {( p6 E. T+ u! Q
; l# I; ~$ ^+ f0 O, Z$ q- l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) x( N j9 {: K
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: O- }: d3 J6 E0 W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 H8 v6 e9 U( e8 a( X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" F+ J1 }' H0 `) d) |) [- ~5 ~
0 ]; |7 K( [9 i/* assign the tl som board LED-GPIOs*/
8 v$ O" Q. c* E' k- y e5 I5 tstatic const short da850_evm_tl_user_led_pins[] = {
+ o* r* J: F. F# k& X /* These pins are definition at <mach/mux.h> file *// i8 P! \# F6 k8 I
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 y3 ?# Z* L, r
-1
' M) M: p# z. n};
7 H! m; \$ ~( f2 h& d
0 U& k7 O6 t. j7 Qstatic struct gpio_led da850_evm_tl_leds[] = {
( a: M9 H1 n6 i" D3 A9 M, Y {0 U# o2 [% F# x; w8 H4 q6 p
.active_low = 0,- i4 U4 F( A5 N0 }
.gpio = DA850_USER_LED0,
M9 V- M7 T' Y) S1 p* E5 o9 ^. { .name = "user_led0",
1 F6 \* f' S/ A, x$ R* H! K5 P0 G .default_trigger = "default-on",4 g% W( N% r. v6 b
},; ^: T5 |! m& ?
{. ~ r% J, W/ T6 N
.active_low = 0,
/ l/ L& ~4 a v7 N D- _4 V .gpio = DA850_USER_LED1,
2 H! G. u& o4 S# P, b- N: t* s6 i .name = "user_led1",6 C- D' K8 }5 P8 C' X# Z# p
.default_trigger = "default-on",( J) N, G t% Y+ n* _4 O
},) {) X Z9 I/ v7 z( W' T
{
3 R. e" f$ n: }) I! m' r5 m8 m .active_low = 0,5 o. x# q8 k% ]& y- f
.gpio = DA850_USER_LED2,
1 f9 I9 R- ?& b: r; { .name = "user_led2",
3 ^1 k g3 G' g. Z5 i .default_trigger = "default-on",
% K) ]/ a: D) w7 q },
7 D& c! V# f. c {
: V. d+ G4 g, @1 N9 g .active_low = 0,9 o. Y" T/ u- x1 G% k! L! c3 Z
.gpio = DA850_USER_LED3,
, z9 t5 ?6 x' M% ^2 T& y .name = "user_led3",
) w, N+ p" P% D4 J .default_trigger = "default-on",
9 `( i" G6 |: s. w4 d/ O },
, D8 L2 f- n; s+ t% d( D};
% y5 {* Q! b* H7 k* \7 d
$ k# `' e8 s# T7 ?, Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# C" E q' G9 }8 t5 F% c8 n: m) R7 A( d
.leds = da850_evm_tl_leds,/ ]! b( a0 O% Q7 n* v$ s) }
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& z5 N3 p$ B5 S1 ~) b6 t8 J4 T};9 Y5 `( r8 H/ u
' m6 l- l1 L/ y8 pstatic void led_dev_release(struct device *dev)
" C4 b$ `. l. M+ w% ?{
" b- ~' E0 j0 S$ |}; a' \3 u1 l) G2 d+ h; Y. W% y/ i
R9 Z! ?$ E$ Z1 D0 K
static struct platform_device da850_evm_tl_leds_device = {. i* k3 @, ^. K! I
.name = "leds-gpio",
3 U: ^( m; N2 W) K' V; `9 \ .id = 1,) [8 V' B: R( p. j) x
.dev = {
$ A( L6 s- O; i; t, `; w- n .platform_data = &da850_evm_tl_leds_pdata,! u9 [, j+ Q# A9 H5 R& Z
.release = led_dev_release,# ]! J# K0 @6 A4 S: U, \1 y, ? G
}6 o- l% A- O: t" ?. x6 a% S) N
};9 y/ ]6 U4 M' D- h
, O8 E4 j+ s" T _- V7 Z
static int __init led_platform_init(void)2 K4 @. @! a) k. V: J6 g; K. H9 r
{
4 ?+ O4 v% D5 J, M$ F1 I x int ret;
5 W) Y! }) Z, }, ~#if 0
, I+ S7 a5 `- m1 a1 D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 N( }) W! t) ~" z- z if (ret)
( j$ n6 _/ U! S y% y& F T pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; |; [0 ? V* t: u9 F6 u+ A "%d\n", ret); _' s/ s; b7 I# |
#endif
; s+ n. q% `) ~ ret = platform_device_register(&da850_evm_tl_leds_device);
( X! R6 _" {+ H: ~ if (ret)( c2 ?0 Z% T) N* r
pr_warning("Could not register som GPIO expander LEDS");
% j9 {: k9 x$ n: M9 S _5 R else
% j8 o1 c; ^' T" g printk(KERN_INFO "LED register sucessful!\n");% C+ T7 I# }2 _/ F3 L7 u, }( L
# E6 X+ `0 b4 n4 I9 N# z; u
return ret;5 Z7 O! V$ ^+ K) B: {2 V
}" l6 ?! t" R" T2 A7 s
4 D# N7 Z7 T) ` }0 [
static void __exit led_platform_exit(void)& ^ O8 j: v4 d3 e) ^
{: R" e# h& g' S+ u
platform_device_unregister(&da850_evm_tl_leds_device);4 f" r1 a9 J5 g; o# n
. a9 ]; G9 b7 y2 D5 w! U4 i, K
printk(KERN_INFO "LED unregister!\n");5 c7 F! o/ F8 f a
}; T5 l3 o9 Q. c- p$ a
7 P* H/ l5 n+ ^8 g) W: p
module_init(led_platform_init);7 Q. a, N: q" d4 P8 I3 D( H
module_exit(led_platform_exit);& o3 g2 x. ]$ S: q, Q% d3 h
3 q% I( V1 G8 Q( {2 D0 o3 H
MODULE_DESCRIPTION("Led platform driver");1 m. w" [, K0 j: J8 k
MODULE_AUTHOR("Tronlong");
1 r+ K9 ^+ e0 ?% @MODULE_LICENSE("GPL");1 `8 m; i( G: f& k+ Z6 J/ O8 Q% x
$ d+ _; o; m3 b' Q
|
|