|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) b7 ?, p2 Q; `/ s
#include <linux/init.h>9 E7 o+ R! Q; Z: D& ]* l! m
#include <linux/module.h>( K/ |" V( l& V# }* T6 S
#include <linux/kernel.h>
( e- R3 S$ x- \% g, I- [#include <linux/types.h>
4 N2 X% X+ ~# q; h# \#include <linux/gpio.h>1 y* S( A" S/ N. Z$ m3 Z, s) B
#include <linux/leds.h>
0 Y; A& `/ H7 r/ E& |' k! A#include <linux/platform_device.h> W/ Q _7 B9 T: a3 f8 C3 }# u
/ M$ A3 e' E4 Y/ U; j9 k
#include <asm/mach-types.h>
0 b+ z8 S# D8 B7 C#include <asm/mach/arch.h># J: P; ?. V. u) `8 X U- s2 G
#include <mach/da8xx.h>1 z* g0 F# x9 g! @! J5 q
#include <mach/mux.h>
2 g0 R. g0 Q7 S% ` s! v0 D) e5 B' z& `$ y5 W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 h# q$ `, O' k/ }7 `2 g
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); z, ^! e2 `0 c8 Q- g& w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 A$ i6 q! Y4 k6 E0 J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* P" b' C2 A; ]0 e4 @1 K
. E8 |( Z9 l! w* f/* assign the tl som board LED-GPIOs*/
8 q+ }+ G- B: _% G- G! jstatic const short da850_evm_tl_user_led_pins[] = {
I' M4 R9 ?! \5 y( q! s /* These pins are definition at <mach/mux.h> file */
# U7 e6 F k6 [/ e& g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: `; j. A, r1 P ~+ o$ O6 M
-1
5 X Q# K( t$ \' L4 ]: _};
P. K5 @+ X5 N$ y( u' b
% }3 ]) Q. w: H S& nstatic struct gpio_led da850_evm_tl_leds[] = {
9 H! E% _' }/ \6 l/ u$ U* h& u {
i: E( R3 R0 b4 Y J- b1 G .active_low = 0,
5 o: w2 D2 Z B1 t; k7 y" \ .gpio = DA850_USER_LED0,
" |9 T, @, d, C+ n; u* y# X .name = "user_led0",$ l% e+ c. a% d- T
.default_trigger = "default-on",
, ~! y6 N5 h' ?! ~1 y: {, P' P: P },( q- T/ z9 ?) V& l( g
{# Y; I2 J' J8 }- A
.active_low = 0,
- K: j$ \1 m( M2 Q .gpio = DA850_USER_LED1,3 I: {/ P- H* O2 j, }+ p" p! }1 K/ T
.name = "user_led1",
0 a; ^! j8 T' [! o: x) P& J .default_trigger = "default-on",6 H6 B3 J% m5 H- E
},
. R. M Z; ?) h' @1 b {
) }1 u# B# V$ O* ?, Z$ S4 q! F .active_low = 0,- M* \7 m" X3 ]: r0 @0 _
.gpio = DA850_USER_LED2,
" E7 \' A& P; p% P( K% j) { .name = "user_led2", y1 P; z" d1 s% Y, P4 \5 ~
.default_trigger = "default-on",
2 k6 u: i5 I- [/ J- A% g },# X% z( E6 w) C" K5 n
{" ~1 T- z0 E6 [7 K: W) ^: f
.active_low = 0,
" d! H2 i" x& B/ K8 ]6 V _1 E4 l .gpio = DA850_USER_LED3,
9 B: R6 Z( k; ~# x, K+ b$ Q1 W4 j: g! a5 N .name = "user_led3",
2 c( v. |* ^1 N& x' F9 j! L .default_trigger = "default-on",
# H/ i4 o- Q1 T( R6 M0 x },. Z5 M0 c& q- b6 _, T, F, I/ Q
};
* t8 e4 j: U. T: a# F7 t( ~- U. R: w. \- z e3 ]% \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 q9 _/ b3 {& ^* }. M4 k
.leds = da850_evm_tl_leds,
( u/ P' U; w/ ?/ {; x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 s/ _2 |- [6 ]+ T/ T) _' }};, I# F- ]$ _4 z; W8 U. u' c+ F( H
& i. D$ s& q8 F7 Q7 A6 {
static void led_dev_release(struct device *dev)
6 G7 a, Q( S2 _3 m1 J{
6 c3 e1 t1 `* A) n. o( f% Q( v- e};7 A% I A: {/ ~& u& Q, m% s4 q$ }
+ x9 \1 W5 d( o' r
static struct platform_device da850_evm_tl_leds_device = {
$ s& L& z5 a$ s7 V; y .name = "leds-gpio",
" d* \( R. H: m6 R. c3 e .id = 1,% o8 F$ l6 I# w& p/ S
.dev = {
/ [6 J# x2 H- A .platform_data = &da850_evm_tl_leds_pdata,
* u4 D9 ~+ U5 t v' n .release = led_dev_release,
4 h a% F- h" \' I; J8 t+ q }
; A R2 a- n( b* K};1 A: m1 C- y. ]# s2 M: X" A
9 \0 O: b& X( q8 s. y: K( {
static int __init led_platform_init(void)( C4 ]& ^) T' {/ t- @5 E
{/ H8 F* q5 }1 `6 v1 _! K4 s6 f; a
int ret;& f! w& a# N7 F0 S/ D! A- K0 `
#if 00 z- |% p/ v0 y( [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. r1 ]* b" W* O! F9 w2 [' L
if (ret)) g' f" x$ _2 G) w( ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ M: `/ D/ V; F$ P "%d\n", ret);
C( {+ b5 O, z. P5 N#endif
2 a4 ^- k# L1 Q" D ret = platform_device_register(&da850_evm_tl_leds_device);4 t( `0 u1 p: w
if (ret)- k5 _, ]& H0 A A
pr_warning("Could not register som GPIO expander LEDS");- p' M1 p2 J) g, H& z: j( O3 p
else
2 g! C$ t C* x3 d9 p& s A" D5 Y printk(KERN_INFO "LED register sucessful!\n");* M3 f2 ]! W4 r# M5 p
( ?0 c3 |, m$ e% C
return ret;3 s, ^3 C& V' J5 G) K
}2 @% |5 w4 m7 Y; a, y
$ c6 O, m$ g0 u3 j
static void __exit led_platform_exit(void)
6 D2 L% |$ K$ P7 T{* S6 o+ r8 ^ L; q2 f, F9 A% a
platform_device_unregister(&da850_evm_tl_leds_device);
: _ R# l$ j: R6 ]" {4 b# X2 I: `$ H# M0 `- G! ?" H
printk(KERN_INFO "LED unregister!\n");
, o# m7 x$ P, K- c2 f8 q}
' ^2 ^1 ~0 w7 _$ P7 e; {3 t* u2 g8 {/ e* m" i
module_init(led_platform_init);
0 ~- m, S4 ?% w% a# `) Omodule_exit(led_platform_exit);
5 w( m$ w, P" v% ~. P( @- {( Z D1 G/ L% L% [: G+ n; o
MODULE_DESCRIPTION("Led platform driver");
7 j; ?1 ^9 T6 \5 }# ?" W$ @/ QMODULE_AUTHOR("Tronlong");7 l1 y' }6 T7 r6 m; G
MODULE_LICENSE("GPL");
; h, }: q7 Q+ s
$ G1 w% t5 Y1 `+ F- t: T |
|