|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# o& N8 E5 M" l3 t3 s+ `#include <linux/init.h>3 Z; H+ i7 { m1 D4 \$ s' R3 R
#include <linux/module.h>
; Y: S8 D" F. ^ d1 l2 U. R#include <linux/kernel.h>, S0 B; s' w4 m1 B; z
#include <linux/types.h>. R6 w* _. v) _/ Z* n4 n* D U0 b
#include <linux/gpio.h> N, v1 l; F F z
#include <linux/leds.h>
+ w4 a0 i5 n* R* {( i) I2 g; }. L#include <linux/platform_device.h>. ^6 |0 w. S% ~# ]5 @1 _
3 C; L k" f! X: I- N#include <asm/mach-types.h>
6 C# ]9 I9 ?: F' R) }" X( b#include <asm/mach/arch.h>( p3 K: {5 T7 g1 f0 m
#include <mach/da8xx.h>
" ~! P2 G' X( {; i" A' V {0 f$ H' K#include <mach/mux.h>
' |* h; @0 e8 ` D& |
/ N$ J1 n( C# x3 _( h#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 n8 z2 w$ U5 s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 K5 \' g$ K9 b/ @& o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 p* X2 K1 k7 v$ [( l+ S" q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* _2 p% G0 t& W. q# \
# E8 a% T* L8 B. l/* assign the tl som board LED-GPIOs*/
* { _ P# D# T: E6 @+ C7 Pstatic const short da850_evm_tl_user_led_pins[] = {
. M( c" D r6 N1 V! D: c( |2 \5 k /* These pins are definition at <mach/mux.h> file */+ T6 P+ G6 Z D6 @: |6 ]0 l! C: i3 H
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ S) M- a6 h1 X8 y5 K% p -1
0 G- p8 y& V, ^7 t# P0 F* \};4 { Z; T& K( a! Y+ ~* k5 L
1 Q2 F0 [+ s n) d# O
static struct gpio_led da850_evm_tl_leds[] = {
' u8 |' m! l7 x7 Q {: R" _( A. W- N$ O
.active_low = 0,; X( P9 ]+ ], M5 m$ o
.gpio = DA850_USER_LED0,
, ~1 m3 v; [/ ~" ?2 R# c .name = "user_led0",4 b; `# J% X. t- I; G0 s6 d
.default_trigger = "default-on",1 M# s) b6 _; s& q& Q
},1 t k, f6 ]# d4 w4 a
{7 ^$ }( C' e/ {1 |5 C% d% y7 m
.active_low = 0,& C, x) I6 S. q, P1 v
.gpio = DA850_USER_LED1,# u# Q3 ]. V ^
.name = "user_led1",, Z* A9 Z" f" y' r5 L
.default_trigger = "default-on",) K& B0 C2 @2 i4 X; L4 Z
},- P8 @: L3 B) j6 [
{( p; p* d, q( N$ C8 I& D5 j* ~ p, h; _
.active_low = 0,7 A6 `/ h1 z7 Q/ t+ f. S% ]# @; t
.gpio = DA850_USER_LED2,
9 f: g2 L+ Y1 O& h2 ] C .name = "user_led2",
" }7 D K, g, G) y; }( E .default_trigger = "default-on",6 [6 A2 e/ Z" ?
},
5 [$ N; Q/ \4 u. `1 N v- Y/ p {
/ d; b; O, r) D; N, \ .active_low = 0,
`8 k/ y9 H7 Y; N3 ] .gpio = DA850_USER_LED3,
$ Z5 ?" {: D, ~- i/ i. z0 `* [ .name = "user_led3",
; R" S- Q, Z" j& w! W4 _) q .default_trigger = "default-on",8 K6 s1 \" H$ S
},
n( E' P' C% C& k7 C};
* G e; A; P+ t& [3 L: k5 ~7 b$ F* S f% I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- a# G4 [. {- y' t8 a
.leds = da850_evm_tl_leds,! s" t, w8 {+ r1 U( S
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# C$ z9 `0 l* N2 h- P};! t6 F% c0 x8 B# }
' H3 m% e" D# j( P, s) b3 w8 {. V
static void led_dev_release(struct device *dev)
4 x/ _; c6 Y8 A{- U' h* X* {7 d* W: g3 s
};
; U' @9 X" e. e9 v0 i& B
. `* V \5 k4 e% I+ Hstatic struct platform_device da850_evm_tl_leds_device = {1 g$ O6 R6 {- ]; T
.name = "leds-gpio",1 s6 v* ^0 b; v9 J
.id = 1,
/ u1 j( f4 d$ M2 ? [% n3 m .dev = {
% N# |2 T: q3 W K4 B6 U; D .platform_data = &da850_evm_tl_leds_pdata,6 Z3 G0 n/ h1 E5 b
.release = led_dev_release,
: N6 A/ t8 `7 ] }
# s" R$ P4 f+ S% }& U/ @};
1 h/ I7 W& g- I) D4 u# F: w0 e* l- N- l6 J: H2 U+ m2 q- C9 @
static int __init led_platform_init(void)7 j, C0 D8 ^' D6 I6 d
{
' ^6 S2 M1 x3 V, Q int ret;
7 E! ]. D6 p R#if 0
" W$ [' a& n* i; r. h# w: S ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 k; {$ C. V7 F/ N! P' M
if (ret)) Z2 C$ O. `5 \
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% E( n3 B [! U1 M "%d\n", ret);
' Z/ ?; u- b! m#endif
) ]: J; J% t5 L) B, p3 x ret = platform_device_register(&da850_evm_tl_leds_device);' q. S: v4 c) @* b( q) w
if (ret)
/ w4 i7 V1 i+ v1 U4 |5 s6 g9 T! L pr_warning("Could not register som GPIO expander LEDS");0 i) O0 q) U* c8 F# }
else* N* H5 y, Z" q6 |# ~
printk(KERN_INFO "LED register sucessful!\n");. p& u9 F' A& b4 X2 x, s: E( _
9 r! m+ [; w0 S
return ret;
v0 ` C5 n' C$ v& `% l1 C/ s! b}3 ]! @# _9 Z$ o4 o! @, G8 f3 S
- C" I7 S( B9 M0 O
static void __exit led_platform_exit(void)) w3 W* t3 |' P5 K7 }
{9 P9 q+ _1 k$ y+ C& l
platform_device_unregister(&da850_evm_tl_leds_device);# J* i Q6 ]0 t& N
, V1 U# u( c- n8 _ printk(KERN_INFO "LED unregister!\n");+ g1 D* p8 h# a# e
}$ t" N. ?5 V$ Y+ P x; w7 t
; i. z4 p+ ]7 d8 c7 Ymodule_init(led_platform_init);9 e' ^ r v" h' B
module_exit(led_platform_exit);7 r/ ?. j! J) \% G
: e3 E/ {4 b9 @( h( W% J1 zMODULE_DESCRIPTION("Led platform driver");
I4 X" T5 ]2 l8 T) y/ ?, R7 v" F$ \MODULE_AUTHOR("Tronlong");
* F; R& a7 }1 E- e2 nMODULE_LICENSE("GPL");& s* U6 d+ A* p2 l' G4 p7 J% ?
" c' h9 `/ l$ _
|
|