|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' W+ y9 j) a" \5 n+ j4 w
#include <linux/init.h>- P2 B- j0 p0 L" J) z! F0 a
#include <linux/module.h>4 t+ k$ ?4 c0 @/ T1 G- c8 I3 a k
#include <linux/kernel.h>
3 j# B6 e# C; ~' H1 R#include <linux/types.h>7 @! ]; n u6 ]; I$ z! \' k6 v
#include <linux/gpio.h># ]! r% f. ~2 n2 P
#include <linux/leds.h>; y7 i& B$ D; J5 _5 T
#include <linux/platform_device.h>- `* N+ t: \( D
4 n6 u4 O3 k1 V# I) S0 K# F#include <asm/mach-types.h>8 [1 n/ J4 M7 C' K
#include <asm/mach/arch.h> W4 a3 b) A: w6 E& M
#include <mach/da8xx.h>0 k; U" ~; T E) y: i! X
#include <mach/mux.h>6 P3 [3 }; P4 @& X
& ]7 I6 f1 X: o. _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 p- V" m/ g" L) R% y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 c7 |' t( Q6 @ U3 `5 b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 k# m" F# C- H: S
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) Y" O0 k1 c. L+ B
% l# L( @4 _; C, v+ L/* assign the tl som board LED-GPIOs*/3 n" V" q8 {7 t6 t- S9 J
static const short da850_evm_tl_user_led_pins[] = {! b# D. N0 M b$ @
/* These pins are definition at <mach/mux.h> file */
: t7 r5 f! g. L5 ^# b2 n# v- H$ X1 S DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, P$ z, h4 ?1 }. h$ s
-1
# z$ ~: d# o v8 z% v4 E};
9 S6 R) G1 i+ d4 s% e0 L) r. y7 i" h0 `' B" j- A
static struct gpio_led da850_evm_tl_leds[] = {" Y4 `0 y& _) | \$ h
{3 s, a) H, m) X% q% i0 N
.active_low = 0,3 j1 i( D" l! o6 t
.gpio = DA850_USER_LED0,
u: d3 }5 I' L4 E4 d+ b .name = "user_led0",( i7 n0 u% q9 T* J
.default_trigger = "default-on",7 b2 B8 j; ]$ J g* | l/ }% u
},
8 t7 L$ Z# p# R' q/ } {
2 u H( v$ v" D/ L; l# } .active_low = 0,
" Y7 f- e7 g* g C .gpio = DA850_USER_LED1,3 H! h6 M- p( H6 X: B- c
.name = "user_led1",
& q6 I( I( g* H" E .default_trigger = "default-on",6 @+ S/ t9 V+ \& j" f
},9 l# h/ Y" W0 M5 B
{$ L$ O7 c" x+ B+ l! d
.active_low = 0,
3 D8 z$ n! H1 X* m3 x5 o: @4 { .gpio = DA850_USER_LED2,3 H' E* F+ n8 Q2 h; {
.name = "user_led2",
/ Z3 I- m- w; Z. y$ {0 p .default_trigger = "default-on",. r7 R: U7 J \
},8 ~3 x( L, P% L1 T, ~3 c
{6 w* S6 d, q& s9 L& g
.active_low = 0,6 E/ {9 N2 Z' o/ q7 I
.gpio = DA850_USER_LED3,
/ ~7 d0 y; D% r1 y .name = "user_led3",& G4 F, j. @9 P9 ^$ @
.default_trigger = "default-on",) x; _4 h9 ~9 z4 ?
},4 z# T7 F) j8 @" H$ l
};
" k( l: w0 [+ j9 g2 F! T4 }+ h7 m4 j" K% O8 @6 g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) o9 X/ ~( V7 a2 I+ t9 P .leds = da850_evm_tl_leds,/ v& _7 T9 R! @( }( @8 K' W% G E
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# q( _' g) s+ ^/ G3 y4 U};; h: v' M* a8 X0 N* ^& Q% J$ ?
9 o) D4 {$ D$ _static void led_dev_release(struct device *dev)
: W$ F, r' k! O/ B: w{( n) {8 B& U" V; Q
};
4 X$ W! q0 s6 s+ i5 y% o: B. q b1 {/ m# _* u) ?) I/ Z7 \
static struct platform_device da850_evm_tl_leds_device = {0 L: l9 n0 L$ N. N/ {9 ~# J
.name = "leds-gpio",
/ i6 G, [' ^ ~% V% I8 s6 n: g .id = 1,
9 Z0 g2 j& S/ A3 d .dev = {$ j! p( ]' O* W1 d5 M# R2 i
.platform_data = &da850_evm_tl_leds_pdata,
% a( l0 l1 p+ X" ` .release = led_dev_release,
5 f z, k* g* w }' g; X9 R" i8 ]( \$ ?' Q% A
};
8 z( t) S2 h5 K
% E2 [ u: B- z% m# nstatic int __init led_platform_init(void)# M6 f5 i6 v3 V4 b
{
+ [, `* |, J* D' ]# t( C int ret;
# r" Q B. f/ {. c5 ~0 u#if 0
9 ^- A4 B K) B% E: L+ l& U8 g4 z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* ^) i2 V V4 D: j$ D. f# }% z
if (ret). V" k* k+ [, ~' G" n. `6 ~8 O
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
j7 n6 r: A7 H9 {1 W+ C- X0 r, p* x "%d\n", ret);5 n4 Y- a# a4 {3 i
#endif
- j8 l, j7 ~5 ]- a ret = platform_device_register(&da850_evm_tl_leds_device);
R6 I$ l4 W' \4 | if (ret)3 B# y; Y$ i6 M5 \) e) @0 ]5 L" Q
pr_warning("Could not register som GPIO expander LEDS");
: r: Y- ^' ]# ^* P1 l5 y$ `" b3 u/ ? else
& P: a% u# {; ?& A printk(KERN_INFO "LED register sucessful!\n");
8 Z S2 z- |( G: `( _% A9 |" L- [+ w# w5 P$ U8 C- [
return ret;5 c; E2 K- E8 v+ o
}* I; [7 d; h6 P
* T; P$ q' C+ \' G9 A: ~6 u! j
static void __exit led_platform_exit(void)" j/ o5 |4 C3 |2 |* p# I
{
0 g7 t+ q" f: }# j, C platform_device_unregister(&da850_evm_tl_leds_device);6 i& g5 Y! \8 P$ U4 \9 ?! n4 O
1 V0 G6 U* n# O
printk(KERN_INFO "LED unregister!\n");& I) U" i% _: V+ }
}4 q' I) `2 O, t. p& I; l2 z
3 f1 \5 }& K/ |* P3 d2 J) [) B" I
module_init(led_platform_init);& O& l1 o7 b7 w6 B5 K b {
module_exit(led_platform_exit);
* r; x M. P/ E
' e9 q: k/ X$ j# T' KMODULE_DESCRIPTION("Led platform driver");* t4 k+ m! {" t2 `$ j2 `( a& }
MODULE_AUTHOR("Tronlong");
3 m8 D$ W; B4 DMODULE_LICENSE("GPL");
4 f# s7 v" I' p
$ B- a3 h2 p5 V; ^$ y |
|