|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 Z9 y/ [) x" `" o7 ]; t
#include <linux/init.h>& D' ~1 g2 S1 g5 o* g/ l% O& R+ o( x
#include <linux/module.h>' z j: e5 P* K
#include <linux/kernel.h>
+ N% T6 B& E. d& T4 O7 Z& G3 I#include <linux/types.h>0 F6 B5 e. A4 }6 S, P
#include <linux/gpio.h>1 R |" w8 q6 n2 ~. l
#include <linux/leds.h>
' a# F1 v" F8 X1 e: Y7 A6 Y9 R#include <linux/platform_device.h>% C: i+ X0 h/ d2 G9 b
5 K& {* k/ k) v7 c# G) W' H
#include <asm/mach-types.h>, P w4 F ^3 a' R* _" |: R
#include <asm/mach/arch.h>* @2 C) e( z4 m2 Z& E, T
#include <mach/da8xx.h>
9 L$ V: X( i$ c#include <mach/mux.h>
) y9 L8 o4 V! F. c( D8 i' N9 V( O A; S
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). u a1 F4 D- R3 y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); `( g# U: g4 A+ |
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* w! x: E- Q. a9 j, r1 R& z2 L$ F
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% d% A8 C, U3 {0 S. @
4 ~0 ], t$ h9 Z, V6 h/* assign the tl som board LED-GPIOs*/
+ _, G( y" C, ]% k/ E" Kstatic const short da850_evm_tl_user_led_pins[] = {; W6 N: @3 X" T& r( o* \% p
/* These pins are definition at <mach/mux.h> file */- f0 x/ K/ z$ L( c `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ Z/ H* H8 B0 t4 x; K) T5 [! e -10 o$ k; O* i0 m* Y
};: x6 z; N$ _& C8 @4 x `. _+ U
# g' V( S5 ^' W2 r& d; J9 O! T
static struct gpio_led da850_evm_tl_leds[] = {+ r8 U9 f9 m; {3 t" C7 u5 F0 F% |9 \
{, \' h* H9 W) \& r& ]& x
.active_low = 0,
' C, Y; `$ Q! E .gpio = DA850_USER_LED0,
1 I& |. F o; \ @, T* k t, c .name = "user_led0",
; P( I8 O! {# M6 { .default_trigger = "default-on",& Z& J4 z& a/ i& F3 |
},
8 a% i4 S7 Y+ r$ y {8 ~3 T1 Y, m! `% |# F+ P
.active_low = 0,+ q- d% R9 L/ j4 w, F
.gpio = DA850_USER_LED1,& ?% t7 N( F- ?% b
.name = "user_led1",
! Y5 X1 U/ H& ~$ ~& K .default_trigger = "default-on",
8 ^ j4 _0 f8 [' U9 j8 O3 {, T },
+ Q0 C% N, m- T2 r2 N% [ {& X( Y. l m( f7 o `
.active_low = 0,
8 O1 D1 d V! T* v1 n/ g .gpio = DA850_USER_LED2,8 i# H0 H5 o$ B2 D4 V- ~
.name = "user_led2",
9 d- p7 {' d3 L .default_trigger = "default-on",
( q. o9 B9 C0 R }," [- l, q" D. w: c/ J |
{6 _2 |. c, a1 A0 u0 c9 M
.active_low = 0,
. Y0 g2 b$ s' j2 g# n$ t6 l, _6 H .gpio = DA850_USER_LED3,
" D/ n. b% v: O# ]9 @2 S .name = "user_led3", Z5 D% G' s- K5 O: u
.default_trigger = "default-on",
) T" s6 s8 F+ g7 K* f1 J },
% c* @: x1 ]0 u};! {2 i5 H: Q) Q) l1 g# d7 X
* c8 [- L7 S C6 k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# Y" K$ d! G7 W& U4 V5 G
.leds = da850_evm_tl_leds,
( u; @3 t) f5 t% g3 N5 [ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ i, R- E3 w4 i};
- B' T. S( [3 ~+ S* b
* r3 P" \/ }9 J w8 ^static void led_dev_release(struct device *dev)+ Z( I8 K. @4 a1 p; l, {
{
: _. B" L& ?) O% p+ ]. V};
! E- V7 o- k/ T( S0 \
" k% I/ J& @+ P; }% p) y- gstatic struct platform_device da850_evm_tl_leds_device = {& O4 J% f8 b3 V+ f& D
.name = "leds-gpio"," n- J$ o n8 e1 I+ d! s9 q
.id = 1,
* K, R: e) J! l# b; I# @* s5 A/ w .dev = {
& E) m7 k; T8 {- y .platform_data = &da850_evm_tl_leds_pdata,
6 p1 u: f% u- g" F3 M; D# I .release = led_dev_release,
$ z6 S' s& F; i" a1 ~ }
) N- b* {$ f4 Z9 j};
R% o" z( G* `* _& m
+ a1 G0 f9 v- i' Cstatic int __init led_platform_init(void)3 h. Y8 |% d: } M4 S
{9 v4 f# y8 `8 h v* ^! ~, N
int ret;
7 S( z# }6 X% ], r4 Z! K- Y& y9 o#if 0
9 N. i% d2 X& j) A l! } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ e. ~$ |, F* ?. ]7 r
if (ret)
4 }# N7 F) [: L2 E0 h pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 z/ _) ^% j. d! _4 s$ z "%d\n", ret);# a* i: R& w' Y A# L; V% `* ]/ E
#endif; \" A# o! j; [7 B% o& m# M, k
ret = platform_device_register(&da850_evm_tl_leds_device);
4 ?9 A0 D7 L% s4 o& F if (ret)
+ h4 K9 h: m: D2 _6 ~9 B: J7 U pr_warning("Could not register som GPIO expander LEDS");; r- y6 c6 z" J* v2 H
else B: _5 [* ?# _5 n8 U5 p9 R
printk(KERN_INFO "LED register sucessful!\n");
+ ~4 G: G* f1 S9 v) D. Q6 a. K$ F
( P6 @$ J3 Q6 l- l+ p" [ return ret;8 m, a9 @5 J+ g# J6 h2 [8 W V
}9 K# T( q) D8 Z$ a
" z# D+ y; b, ?. e# r' H9 Y
static void __exit led_platform_exit(void)! w/ |- z1 w# e+ M+ z4 \- x8 v
{( R$ B$ ?, q: H4 B
platform_device_unregister(&da850_evm_tl_leds_device);* c s5 {! `* B8 p$ \3 {3 t/ i( `
) {3 N% e/ ^+ n- C printk(KERN_INFO "LED unregister!\n");5 C2 i$ c+ N- J: K# M8 b0 m
}
( t/ q9 ] l# _) O$ ?3 V( ^/ d; O2 }4 ~* g
module_init(led_platform_init);6 L7 Z+ ]4 j m" e4 A
module_exit(led_platform_exit);, u4 l" o6 y+ _# {/ t
. V3 `: r9 S- _MODULE_DESCRIPTION("Led platform driver");
$ }/ P8 V+ i8 S3 w! DMODULE_AUTHOR("Tronlong");1 X; Y0 ^7 ]4 c
MODULE_LICENSE("GPL");* \ `& t8 [- R* t3 e
- T# c7 _3 w* k |
|