|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' _9 D) \: ?/ w9 J" j
#include <linux/init.h>/ F. z6 U$ l* J* L6 P, ~: Z, }$ b z4 \
#include <linux/module.h>
+ _) o4 p; o7 G0 L# r+ [+ T) }) N#include <linux/kernel.h>
0 h% E7 ^, i _: z#include <linux/types.h>1 _6 F# o! S7 R/ @! C! W
#include <linux/gpio.h>5 V5 h' c2 ]: i
#include <linux/leds.h>% t7 g r' i& w+ N% C
#include <linux/platform_device.h>9 R& k( ^6 _+ O: s4 q' S( P
+ g- W" v) e- e4 F& d6 F9 t3 w* b
#include <asm/mach-types.h>4 ^1 j! q& c0 ^) Z3 y' @8 @
#include <asm/mach/arch.h>
# Z! \) N2 n8 ]# l- g! B' n j1 t#include <mach/da8xx.h>
$ X3 u3 a! G2 ?4 J X. [( m#include <mach/mux.h>0 n+ B- D; d0 `( G0 r/ q: z/ t$ l. G% t
+ r3 A! Y+ ^/ w$ @
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 @2 H: K _. @6 L#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 J! u h4 R% G7 P5 f% |. W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 i+ V9 n2 y; i) s" \) y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 c% U7 G: t" E% U% F2 A, I( g
+ J7 ]* Z& q- _( L/ X1 p5 K
/* assign the tl som board LED-GPIOs*/; ?( N" v) i: p
static const short da850_evm_tl_user_led_pins[] = {
" i& n" T7 c! K% w /* These pins are definition at <mach/mux.h> file */7 i8 D" W! n j a7 J( g. R; N
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 _& Z/ b3 u0 e& m
-1
- O# y' \. E: J8 k7 M};0 v }9 d6 v/ y; _# F) J7 [3 ^7 \8 g3 T
+ a: D$ p! W' u# q2 Sstatic struct gpio_led da850_evm_tl_leds[] = {
! W, |0 J; o* H9 q7 k3 {# [2 I {
c$ V6 g! s8 h& o! I; l/ Y. N .active_low = 0,
, I* l4 A! r, f7 y6 K& Q" t .gpio = DA850_USER_LED0,
$ n/ W- ]+ p: s9 V- [( b2 q .name = "user_led0",
' n) U+ Y/ w( K8 ~5 r, {- K6 W! v .default_trigger = "default-on",
& C6 N7 q0 H" ` },& i% K+ ^) H9 }5 I( m$ C5 t0 Q3 g
{
7 w; |+ ~- _% J3 c) F, V4 t .active_low = 0,
7 i( x2 T9 \( \% F6 X7 Q1 q .gpio = DA850_USER_LED1,; o& b3 i+ Z; W( g
.name = "user_led1",- r- r/ Z, N. f, Q
.default_trigger = "default-on",
# w+ v3 O& s5 z: `4 Y },* e% H i8 W9 _8 Q( x H
{7 ?/ l$ Y0 m# N6 ?- R; \' I
.active_low = 0,
0 f9 i4 e$ O1 v& S3 V .gpio = DA850_USER_LED2,
2 G5 k% M- s( i5 ?- k .name = "user_led2",
* {8 ]; y6 A O .default_trigger = "default-on",
/ K/ ^3 m6 ~4 m },
; V7 E4 _( Z8 [' @% [1 E {, T5 h/ u2 g& a% G. g4 ^
.active_low = 0,) `/ \$ I \/ V: F5 n
.gpio = DA850_USER_LED3,
% V6 d F& P. F .name = "user_led3",$ T, }3 H1 m9 N) h, ~+ I7 X
.default_trigger = "default-on",
' D8 u) |: I& Q- J& ~- L7 y/ } },
, @; }1 Z: `# |};
, L5 a' f' F4 w+ ~7 g7 {
) ~3 t4 f$ Z6 K6 e# B( Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 {5 E+ N9 G- D! Y1 O* V" o# A .leds = da850_evm_tl_leds," I# Z$ \, u3 j9 P( @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," @8 ^ ]3 E0 l1 f! Q! [$ _% }/ o
};3 s/ B. D# X8 D( e' a; z
/ V: ~ A5 U) N$ \static void led_dev_release(struct device *dev)
A, w( l+ u% U{' v/ ~/ M0 E; Y% q
};' R2 n' o- J. I5 z p
4 j$ N9 o4 ^4 Z. Wstatic struct platform_device da850_evm_tl_leds_device = {
) w: E% a" S! s' x9 Z( m .name = "leds-gpio",/ q; |6 @, Q, U$ S Y
.id = 1,
4 f4 }8 V) o$ T2 \9 z .dev = {
" d: G7 w: s8 m7 x$ x .platform_data = &da850_evm_tl_leds_pdata,- W) t( u5 R: R
.release = led_dev_release,4 [5 i8 P% w& w4 f. w" ]$ O, k
}$ r- s& b+ G! y9 \
};, W! ~* X! e/ o* T
2 D) p. D' B3 U$ S# Q# L
static int __init led_platform_init(void)
/ r* B( t! _, K' @5 W" C5 K{4 E8 ]5 d& A! l7 ?7 c( C. Z# J
int ret;5 _4 @ Z) W+ H* t
#if 0
) I4 K% ?! t- V2 x: n! R- Q* G ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ P- b" J" a) _& ]* o$ A( m4 T
if (ret)
# W: P8 T8 N4 `) k8 [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) t" F- [% I9 a3 h "%d\n", ret);
* \/ E7 d4 ^& O" N& G#endif/ z- b2 x- @1 p2 c/ P4 u1 n4 n0 Z
ret = platform_device_register(&da850_evm_tl_leds_device);
! ?+ V$ Y0 S1 }9 _ if (ret)2 v" C- t' S( m0 L% a' R! @+ }$ \
pr_warning("Could not register som GPIO expander LEDS");
( [$ |9 Z' }$ ]' Q0 u else2 I/ H3 N2 i+ p! p3 U7 c, o
printk(KERN_INFO "LED register sucessful!\n");- B6 P: P8 f y* T/ X% f; s
% Q+ C. t, S E# X& y
return ret;
' T9 E* u) y$ R4 P* H. I1 z}4 C) N, g5 S* q2 p1 {- ~* G3 I8 l1 Q
# w7 }) I! l# t3 `, }: cstatic void __exit led_platform_exit(void)$ n: G8 u' p" O% F2 K5 y [
{
8 G. Q% U5 }: T- Z4 w1 d% Z e platform_device_unregister(&da850_evm_tl_leds_device);
4 R6 u: M9 a7 J0 n% T( x0 s5 L8 s0 s$ @& @
printk(KERN_INFO "LED unregister!\n");
5 F- c4 m1 W0 d" o" Y3 j}2 k! n* A+ C6 {
$ E* u. s2 Z/ {- I7 H! d5 g( Z# }* @module_init(led_platform_init);8 J( W& l. b) k. C' Z4 A" q/ p
module_exit(led_platform_exit);6 Q; w, d+ M, A6 |7 |) W4 T
+ d1 |7 b+ l9 ^3 M$ DMODULE_DESCRIPTION("Led platform driver");
5 _( E `8 b' P; BMODULE_AUTHOR("Tronlong");" d* S" n. \2 D
MODULE_LICENSE("GPL");* k. ?) C- ?$ Z/ l1 _3 B
) O* n! `3 S& M2 G
|
|