|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: g9 e8 _9 [* Y# v: C9 H+ Y8 O
#include <linux/init.h>5 H. m8 @) T* x: G5 G) t
#include <linux/module.h>$ Z, `" {; H Z5 D; e' h N) ~
#include <linux/kernel.h>
5 O* F9 @ h" L( Q" H. X* s#include <linux/types.h>
2 H8 I1 i/ X w/ n6 ]* \1 R5 _#include <linux/gpio.h>
* z) H; B# |) j#include <linux/leds.h>9 l' _! Y# ]& T. } u
#include <linux/platform_device.h>4 y& O4 T- @) J8 R3 r
6 P( ?7 {3 G- @; D- O' V. L
#include <asm/mach-types.h>. ]/ x# u+ H6 j
#include <asm/mach/arch.h>$ S5 |% r y* G5 f& Y5 \- X* j1 p
#include <mach/da8xx.h>
# H1 J: {6 t3 N! Q1 `9 d* J* ^, L#include <mach/mux.h>
2 w, E# g6 n* m: q. [6 f5 o% \* a3 Q) ]. M: M) H7 a
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' q5 V. K7 [, Q9 p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). L9 C1 R# E& [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 G( l; r" n9 E' W9 P2 D% p% h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% F v- x6 [6 y2 ]7 Q' Y
9 P9 S# n- C' @3 S/* assign the tl som board LED-GPIOs*/
' j% w. y0 a+ ?! tstatic const short da850_evm_tl_user_led_pins[] = {. @3 \/ m" k4 I1 b0 h0 k
/* These pins are definition at <mach/mux.h> file */, F: G* ?. p2 x" `: s6 p
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ g/ u. k _3 v g -1
: ]4 U5 i# l/ P3 G$ j- Y! H# _};
R% i! x3 K4 C5 l" i) m9 s4 g1 |3 s
static struct gpio_led da850_evm_tl_leds[] = {
: N! i! ~0 F3 ^8 C {6 v5 b% L0 g k/ Y6 l3 E
.active_low = 0,
' g2 Z$ X) Z5 G, B* V .gpio = DA850_USER_LED0,! n2 x* ^1 f; O9 U" V
.name = "user_led0",
) J4 v: f7 ^- g( f: J .default_trigger = "default-on",/ F& g. w* G. X( c3 Q. t
},1 R4 x4 i( q8 F* V) `
{
& M2 m3 d8 T$ X9 P1 E .active_low = 0,4 |8 x6 d& n* {* D' |. b/ ^
.gpio = DA850_USER_LED1,
5 s) w! W: q/ |2 _# K .name = "user_led1",3 w1 W6 o! A0 Z [8 r, d
.default_trigger = "default-on",0 m2 p" e" M0 B. x; k+ c3 ]3 D
},5 z' K! w$ b8 O4 ^8 i8 \1 j. R
{8 v7 U; l6 \7 B' f0 J
.active_low = 0,
1 g- u/ D9 v; E' n) S .gpio = DA850_USER_LED2,6 x5 \6 N3 z- E t
.name = "user_led2",# o0 v$ m% [2 N- Y( q
.default_trigger = "default-on",0 K, R9 t0 p5 ]7 W8 x# f8 [, o8 C, u
},
( c: E- ]9 d6 J8 p; _ {' x1 i; L7 M* s2 p
.active_low = 0,
1 E7 f% a3 g- z. a .gpio = DA850_USER_LED3,
; V7 L# x3 V3 k" R: k! R .name = "user_led3",! s/ ^3 E# w. Z' l
.default_trigger = "default-on",' a0 p8 E+ f; _; ]* A
},
5 G! S# K, _3 \+ V4 k, h};$ Q. y( q1 x& p0 Q8 b
: h7 e4 z3 L! F7 N( l; L, Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; ?2 Z5 A1 v# G R! P1 U6 |( R .leds = da850_evm_tl_leds,) t& _7 [) Q) k0 J& }( h7 e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; z) @5 `# E" _+ B5 J, s0 U, {
};
8 G4 B6 K8 t" h0 i) d" D) a$ j1 M$ z/ V/ ]
static void led_dev_release(struct device *dev)& E7 R; T5 i2 H2 p
{( {# h& s9 K; i* O
};
/ W, v( r2 R; v7 j9 S6 [( p& [$ k8 X: ^6 x" V
static struct platform_device da850_evm_tl_leds_device = {0 j9 Y" S& o- V
.name = "leds-gpio"," k. [ [6 k( {* V5 H' \
.id = 1,
2 e- h0 {+ J# T; P4 n .dev = {
: n+ r; Z# U* [9 E& g% b .platform_data = &da850_evm_tl_leds_pdata,0 s8 e+ n0 v% [) w" ~0 K, R
.release = led_dev_release,$ x4 i+ S4 ]/ t- F+ J% O
}
8 i8 ~2 t: Q% p( B( p- _};1 t- e7 w9 r' V, F, c
, [4 ?$ ]# Z, {6 k3 s7 {% S3 _2 v
static int __init led_platform_init(void)8 ]+ ~- x6 o4 _6 A
{
& D% g+ [6 R' P6 O) x& ]! G int ret;! A0 {% n- k5 `" I1 a) x2 p+ Z
#if 0
! e- B. K$ D+ ^/ I5 E3 \5 Z' s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% o! J* n' P! Y) M" M
if (ret), m1 z" w' i+ b# K! f' _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* u, N; p# j' L* K; Q/ U, `
"%d\n", ret);7 ?; B8 |+ I" A& s
#endif
9 a5 b0 p, a" W1 t3 e ret = platform_device_register(&da850_evm_tl_leds_device);- e9 B) Y! Z- O# `
if (ret)
2 o6 H, F3 o& X pr_warning("Could not register som GPIO expander LEDS");
" @3 M3 q; |( @3 `* S( k+ K& w! t else
, |1 o1 \. i; \! v6 |, Y- l printk(KERN_INFO "LED register sucessful!\n");' M. F+ l$ i; W4 g4 ~9 S5 X
/ T" p# N9 M( n3 V- K return ret;* W0 [: y z8 {) [
}
, A/ E3 J% b+ w6 k8 z
6 @, @+ Y7 m vstatic void __exit led_platform_exit(void); o. S _3 T0 {) Y
{
. i% \' R" A8 q$ V$ h platform_device_unregister(&da850_evm_tl_leds_device);
$ s& e' b" n3 h- N$ l( s
. [- ]& I! n/ _8 \2 H; D printk(KERN_INFO "LED unregister!\n");# |0 b" R# I5 \2 {
}$ K) Q/ q. S1 H
: _1 G @; v y. F4 |module_init(led_platform_init);5 K- W0 r. R$ F0 @. M$ s3 k/ h* {5 w
module_exit(led_platform_exit);5 L! h0 a' M' P+ d; ?1 ^
5 c3 o- }% ]( q! p- e) x/ @6 @
MODULE_DESCRIPTION("Led platform driver");/ h; o+ k2 f/ \: ~9 `
MODULE_AUTHOR("Tronlong");" W( p. p& ^$ I& `: c1 B" E8 x# @- f
MODULE_LICENSE("GPL");. j; ?; z6 y0 N4 F) }) }3 T
0 a5 k6 M+ g8 V2 U$ g
|
|