|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 j1 Q/ x, K' ?$ k7 O
#include <linux/init.h>
/ M7 d+ V& B3 `9 c#include <linux/module.h>1 L' A& z/ s# _ x0 g
#include <linux/kernel.h>8 k, |9 A- `6 c& d/ V, C
#include <linux/types.h>. r* P/ m# W. K1 b( e0 I6 p, X/ d1 W
#include <linux/gpio.h>
% l8 g1 W" I0 k6 T, q0 R' e#include <linux/leds.h>
* \3 ]( j% A8 Q#include <linux/platform_device.h>$ [6 ~# l/ [. H7 V& @7 b# T P, q
3 N+ L0 t5 t! u. i! q. c#include <asm/mach-types.h>) Z; i ] S0 x& o5 B: y5 Q, Y
#include <asm/mach/arch.h>
) i& c1 V3 d7 T& B+ `#include <mach/da8xx.h>
9 Q- Y8 c' e% k/ P; k" V#include <mach/mux.h>
6 {. \: \8 C8 Q0 a7 E% F
8 }+ N; I( n ^#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* j; `& v; H7 e/ e# }$ ?% _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ i. I" ~" V& N& u$ P! r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* W9 x$ g$ Z% X/ f$ {8 m9 n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 J- s0 M5 x* m( u. D; t* A# t
6 n7 C2 u8 Q6 S- A( n7 @7 J# [7 @
/* assign the tl som board LED-GPIOs*/
* P) c& Y7 ^7 t+ G( \& Istatic const short da850_evm_tl_user_led_pins[] = {
3 r& e: [9 Z9 j0 x; P% x /* These pins are definition at <mach/mux.h> file */* k6 ?. G2 P* Z/ o& N
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ u% f; ^0 i8 a( @% w, ?
-1
$ r O+ r S! ^; w1 z) i& G) H- c};
6 @ X1 z) m, S/ z. I% j) H% K
( i: a' V6 [% c* mstatic struct gpio_led da850_evm_tl_leds[] = {
; b5 y8 O( ]: l5 R3 i$ R8 M {
5 y2 O" Y! T# b .active_low = 0,
3 x1 l8 ] u+ M* ` .gpio = DA850_USER_LED0,
5 n' b# W$ y" Y2 f" a& W .name = "user_led0",
/ a: P; a5 ^8 B .default_trigger = "default-on", W& v- s# k$ l% Y1 \5 w/ ]" w4 _3 h
},) K. e: ^( l8 H# `
{
8 |9 }3 M. w! `. p6 ] .active_low = 0,8 S2 i( r# J* C
.gpio = DA850_USER_LED1,
2 F- i7 L6 Y# K3 d" _4 B2 @, h .name = "user_led1",
" A# y, O7 x6 F' ~) N7 Y+ J1 s$ S .default_trigger = "default-on",
3 T" C1 o* x6 A },' b$ y' P; [# g2 d1 c" `8 Q0 K
{- ^0 O" l# W0 }2 d# z/ e
.active_low = 0,
7 P a0 S- N; D" v9 G& ?0 G .gpio = DA850_USER_LED2,
. n, c! D8 j7 V( D .name = "user_led2",$ I, J" e* d# `* U
.default_trigger = "default-on",
0 k. x( t \( ^ } },8 H! ]5 F- t$ L0 d5 z
{
! u. q9 G9 Q6 Y' S8 q6 q .active_low = 0,
- u! A/ m0 i E, c; |9 m& @ .gpio = DA850_USER_LED3,
" f9 G* ?' {- N$ X .name = "user_led3",
k2 v/ r* C3 E .default_trigger = "default-on",
p# j0 v& Z) i @1 ^! P },) ^7 T" D# [! {/ V w; S
};
) P" A7 p) n: F* m8 w* p' l8 b5 h7 U5 e6 Y, x* u
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, x9 ?6 t; T. d; W
.leds = da850_evm_tl_leds,: z+ j3 B H3 ]4 F, J$ P! U& L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% U0 {; x; z) }* z/ l/ I1 x};! t% X$ ^) g! J" D1 ^. q6 g( B7 w
3 y3 h7 X1 u5 u$ Z7 j* ?
static void led_dev_release(struct device *dev)
. u# J, i- q! d a7 c! o+ O{
- `3 v$ n6 ^" ]+ I- i+ B m4 k' U};$ X! L7 d! ` [$ O& K9 G
' V+ _) u. v/ ^3 h& \- Cstatic struct platform_device da850_evm_tl_leds_device = {4 z1 l! ~; r% ^! M
.name = "leds-gpio",5 ^+ D% }; D' l
.id = 1,6 o7 T+ r! [/ V- k7 M
.dev = { m: S. b: g: j6 I
.platform_data = &da850_evm_tl_leds_pdata,. w4 V. @" P7 s: n. t+ [2 z$ x! {
.release = led_dev_release,
8 Z" [; q6 w Z }) Y* E( y, k( R) u; ?6 `- t+ w
};
! x# d O" y& A. W5 d7 ^+ R& j1 m# J9 b5 f; ] E
static int __init led_platform_init(void)% k- |. s* ~. Z* \
{# H* j9 w% ~* F9 I4 z& A, r
int ret;
- q6 f% s; Q# G) h#if 0
2 U9 ^5 f% Q( [. D" Y' D) a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); Y1 E G% z/ L {/ R
if (ret)( j( ^1 Y% }0 s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 f, A/ S8 M& @& p/ [7 f) z4 j "%d\n", ret);
* W) B8 ]. e- e) R$ L, X4 D#endif
' T: w* `, f4 ? ret = platform_device_register(&da850_evm_tl_leds_device);
! V8 z% T9 g5 B- W2 J: g! n% f if (ret)9 L& ^/ [; I; C2 s% J# B) ?
pr_warning("Could not register som GPIO expander LEDS");
7 ?$ T" K5 Q% U' I% b( v$ e9 O else i. V& _7 ^5 r2 X9 A; f, C M
printk(KERN_INFO "LED register sucessful!\n");, M2 X) W X$ j! f( w5 B
- B7 Q Y0 j" r& }( X$ p ~# W
return ret;; l) S# ~- y9 ~8 {9 C+ S9 c
}
6 ~$ @( V* {0 \# E- D3 z' h6 X
/ S+ A; z" ]5 H5 o7 J9 ?static void __exit led_platform_exit(void)8 d+ k5 w. o* W _3 G9 I- J
{9 u1 \" A6 \) z/ h# I
platform_device_unregister(&da850_evm_tl_leds_device);
& J0 ?- q0 ]* K6 V f; d( D, Q) a8 y" k( l0 [
printk(KERN_INFO "LED unregister!\n");$ H! w) ^4 I" F; L, [
}
# j# H6 p$ J9 ?" L7 G) F* K* u, L& V$ j' G. {& D+ X" M- U4 t( X
module_init(led_platform_init);8 O& I( L% P" t* K
module_exit(led_platform_exit);- l# p5 ?( l& e5 o$ Y* x' W1 k8 b* \
# C) O& V) x0 W/ Q! g |! R
MODULE_DESCRIPTION("Led platform driver");8 u4 ~$ L3 H) `8 q
MODULE_AUTHOR("Tronlong");
7 S9 b% J( B4 e W0 W8 ]( ~MODULE_LICENSE("GPL");: B- R# w% G9 I6 P; `" r
# k/ m8 Q* G6 f |
|