|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( b' _7 P3 r3 j( k9 j, l6 i
#include <linux/init.h>
# I0 l' K& E/ ]: t& C, a) h#include <linux/module.h>
1 m: S; X" y( j# F#include <linux/kernel.h>
3 Y$ O- p8 V7 O( J8 N#include <linux/types.h>
& k' i. C& ^8 }! E0 s" B, J* K#include <linux/gpio.h>
' O, `3 S8 \4 w( H#include <linux/leds.h>
( ~; X' ^2 U( i, X' b! ^#include <linux/platform_device.h>
& R4 z# w" ?( Z3 y; ^$ Y
0 l+ B( L$ a, L, K4 I4 e9 G#include <asm/mach-types.h>1 G( e: y8 j! f: x$ Z. B/ k
#include <asm/mach/arch.h>" E% y" j# _- E# M% t2 g( a, h
#include <mach/da8xx.h>
0 s( r3 E$ \1 N8 ?& H#include <mach/mux.h>2 B- m* m6 R2 G i5 I; [: k G
- o: {- l9 k, I+ T" Z( o
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): v+ p9 C. q2 t" T9 |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 o6 W( F+ {+ K% x9 M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ O5 F( E4 |% h, W0 E7 G* f#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! ^7 x% ^8 n2 P* p% }. }# T# J1 O" Z
/* assign the tl som board LED-GPIOs*/
+ I0 ^/ l/ e. k4 s9 b9 z9 vstatic const short da850_evm_tl_user_led_pins[] = {
6 z# |. G9 E. |% |4 l' T2 \, H* Y /* These pins are definition at <mach/mux.h> file */; M" X6 p% w0 k+ J9 Q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 Q* q; r2 g' [- @: a8 S% y+ q -1* R/ ]# W3 L/ \) b
};- _+ A& v! W7 A8 p2 \
3 E. W/ i J- C( z
static struct gpio_led da850_evm_tl_leds[] = {; f* ]2 s9 N y/ [
{
" B0 v& x2 O8 ^7 _+ e .active_low = 0,+ `8 B& a* @+ C- r3 e+ v
.gpio = DA850_USER_LED0,4 I+ K6 p: ?# G
.name = "user_led0",# d. V4 @! G$ }1 \
.default_trigger = "default-on",/ P3 {4 `9 g4 f2 l. @$ T
},; @. @7 ^/ }9 V5 x* i
{
) b/ C7 W9 l) C .active_low = 0,# ^ e: e. X% S
.gpio = DA850_USER_LED1,1 s2 Z' ^; d8 G& i2 z. R# \
.name = "user_led1",! |3 j$ z2 @# O' D- M5 w
.default_trigger = "default-on",4 S- x* @: U) u
},. C1 n! R3 j* h+ n/ K: C% U
{
- D" n4 J. a; O .active_low = 0,
* {8 e- i& @4 |/ g .gpio = DA850_USER_LED2,6 e+ r% n7 T( ]1 p: u
.name = "user_led2",0 A3 F3 G, k/ W2 z4 m
.default_trigger = "default-on",
. o+ X: X* C- [ },% Q3 |0 g4 D W5 M0 v$ y% ?$ K
{6 D6 L0 T' C+ [! }, A
.active_low = 0,
* G) A, k, c4 a; _3 n- i .gpio = DA850_USER_LED3,* K# b2 }1 K. y* k# W* }
.name = "user_led3",
# @. d4 Q0 j l+ j- Y+ ~+ [ .default_trigger = "default-on",
: S0 }- K2 u8 o& H },/ P4 l% W2 ?9 u9 c8 B; v; N- M
};4 }, g- Q4 K, L5 w
" \' O2 N# T1 ^8 |- O; G# v; h I# ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 |; {& S/ E1 j, o' [1 G
.leds = da850_evm_tl_leds,
6 d: i: c; l% Y! U# j, E" N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ t& u' ?( S) V9 t& t7 T" X
};( X. F; E% V0 u! d# p; M
5 J6 e( C3 { o% ^: C8 R# Z; p
static void led_dev_release(struct device *dev)
2 ^/ c& b9 Z( v5 L, d{
! R# f( J! ~% N" w/ C; ?};
- d8 a1 B6 v3 d" z$ c( ^% H. \
static struct platform_device da850_evm_tl_leds_device = {
/ g! ?4 d: U' u: I8 s3 K .name = "leds-gpio",( q/ y/ c8 D: e
.id = 1,
0 p" ^0 j! V. I% N2 B .dev = {9 c- b& J3 _' U' l0 {, C9 ^
.platform_data = &da850_evm_tl_leds_pdata,- S/ v) L, D% {( k2 l
.release = led_dev_release,
6 y$ `2 g/ r% _9 Q }3 @& |# ~' Z: r" I0 J: t. F, x4 w
};2 @7 j! Q1 v G& D
7 ]7 u0 B% Z D! e
static int __init led_platform_init(void)
; J# B" B8 R- V5 E3 d3 {{7 P" G6 g& h \5 e i& w
int ret;
. ~) Z# T: Z% v#if 0+ }% j6 ~. r( @ N6 O/ y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; I& @' O" e* j- a# N
if (ret)1 `8 {. f5 o0 O, r, W( \# }
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* |# o. J5 A- ^) U, Y "%d\n", ret);3 H6 W. `( x2 a
#endif5 M4 j' }" Z$ Q! t; J2 L5 j
ret = platform_device_register(&da850_evm_tl_leds_device);
, p* C3 X) N7 a1 E0 O if (ret)$ E" p4 S4 I- H2 G6 ^9 p9 M: G
pr_warning("Could not register som GPIO expander LEDS");
) m3 t6 I8 e* k else
0 \$ S( b& b8 ~ printk(KERN_INFO "LED register sucessful!\n");4 f* r( r1 u+ z* v1 h2 T
/ y: y6 i$ Q$ ~/ v; r' Y9 p
return ret;7 J3 k. {- O- Z- H/ U
}
( ` m( c! M4 k# a2 _; T! W: V% c, `4 E( E+ C. Y, a3 Z
static void __exit led_platform_exit(void)% H& |! J( m: y- ?, |3 }. ~
{7 e" d& L& u6 I# p) P# G3 d+ |
platform_device_unregister(&da850_evm_tl_leds_device);5 ^0 R, I* p; }4 |2 K7 K4 f
' [) ]+ w& ?) g4 ~8 k6 t2 t printk(KERN_INFO "LED unregister!\n");
) A2 B3 i# L8 T4 Z( ]- E" H: {* Y}' u6 A. L9 {7 q: X
5 S: e' o1 G9 emodule_init(led_platform_init);
3 m3 V/ ?) k9 E. V+ V: t6 P# Jmodule_exit(led_platform_exit);) N& j+ V l& {9 U$ l6 E5 v
% _0 z! Z& y& z* C, ~
MODULE_DESCRIPTION("Led platform driver");
' p% k1 `/ }/ NMODULE_AUTHOR("Tronlong");% _! _+ e/ h" Y
MODULE_LICENSE("GPL");
' r4 g3 b7 y! l1 a! n% h) Q0 q
( `+ O) ]. Q; ^& c( u: J0 X* p+ W4 ] |
|