|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 ~, E2 z4 M: X8 E9 j. H
#include <linux/init.h>
2 l, C) }( a( s2 d; H/ d#include <linux/module.h># [" L3 i* H" k3 w
#include <linux/kernel.h>+ r1 u3 N, K1 p2 W0 E% U j7 i( S
#include <linux/types.h>
. a: U, H7 A0 R/ }( ?7 B; k#include <linux/gpio.h>1 \! |; W) O+ J4 p2 t
#include <linux/leds.h>
. S: c0 g" ?2 ~; ~6 z8 l#include <linux/platform_device.h>
' F8 z, o- b: s4 D( t3 k4 v$ V# N7 q1 U+ E. _6 e: I
#include <asm/mach-types.h>
. c# f! j* [5 k8 }#include <asm/mach/arch.h>
& {+ I" B9 j& I! c: u) E1 b1 ?: Q#include <mach/da8xx.h>- b2 E2 j1 Y! e& Z7 i, W% w* ^
#include <mach/mux.h>
; ~' q, C3 b( K( \# f5 `# y3 d- C6 Q: p
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 j c3 x) T. n2 S% d5 g
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 n' g3 v4 k) B7 `$ h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ ^$ J6 Y( s2 O5 @' I; z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; \+ [ A. Z8 M) o( w o/ D7 h1 {1 i+ d# v9 P
/* assign the tl som board LED-GPIOs*/, z# c( l/ w! }3 e1 f3 n
static const short da850_evm_tl_user_led_pins[] = {
) ^- _' l$ {- C6 ^ /* These pins are definition at <mach/mux.h> file */
" n# ^( I, a+ ?. o7 V( c$ c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 x' I# D% }5 f1 Y/ W
-1
0 B! I# ^, d$ q% }};
/ U' o; C5 c, Q* I" S$ K/ S7 n6 K( P! b7 ]1 Z' U9 _' ]
static struct gpio_led da850_evm_tl_leds[] = {
/ Z. j, ^% G9 d4 C6 y* B N8 C) ? {
1 S* o: Z% ^- _/ }4 s. i .active_low = 0,7 R4 v5 f9 f5 D5 _1 b F2 Y# E
.gpio = DA850_USER_LED0,
% u8 r& j, I; k0 t7 H; C$ b .name = "user_led0",
2 p6 y$ m6 h) E# s+ r J .default_trigger = "default-on",
9 D+ q' K2 P/ G. V- Z },
) M W7 Z6 u8 g3 q+ H! u$ p% J {9 `# v" _% i/ l" |3 n' Y
.active_low = 0,& j* V$ e# }$ S/ w. f/ D/ G
.gpio = DA850_USER_LED1,( P8 u2 h L4 d* S2 I2 ?# U
.name = "user_led1",, p: O' ^: n- A& A
.default_trigger = "default-on",
) P' S1 r% Y6 D6 l: G: d8 _ },
, {8 i, ?# f5 z* X& H m- y {* s9 X+ K/ \8 T& A: v" ?( D
.active_low = 0,
8 C/ l* J1 A9 }0 `) d9 w .gpio = DA850_USER_LED2,6 A2 M" P; W" u3 a( t( H8 V8 @' o
.name = "user_led2",3 g8 N: y) y$ r9 K3 j I
.default_trigger = "default-on",
0 _& o0 X0 _ k' \7 E, k" t },
: k: `0 F" ^% B; _8 r5 F {
& f Z- L9 D/ H; k .active_low = 0,5 M2 k1 p# \8 E# K" L5 T; k
.gpio = DA850_USER_LED3,* E' [; e2 ~9 V1 B) \
.name = "user_led3",6 p6 K; U( {5 r$ i" g* R! w
.default_trigger = "default-on",
3 G2 U$ J" v, L! G& f }," D4 F& I( e- N& @
};( a" s. {! W2 q D
9 t5 s0 }9 v C xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! H# L% j/ e* \* p! ?* Q
.leds = da850_evm_tl_leds,. e" |$ d8 e9 t" Y- |7 N( `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' b7 C2 I4 L1 \- b}; }* C0 A: z6 u* M+ f8 N6 v
3 P- f8 S V) G9 V# P3 x
static void led_dev_release(struct device *dev)
7 R6 ?, `8 `/ x. P9 d2 B{& P7 _! {* `$ a$ f4 b
};! T* H- z1 R' f. T# m
( {7 e& ?; f6 _" @: @/ ?9 [
static struct platform_device da850_evm_tl_leds_device = {) K$ G w) l p7 Z
.name = "leds-gpio"," ^ T0 f+ X( S' G
.id = 1,9 \8 {- B+ ` F9 p$ |
.dev = {+ `: c w2 H. }. `# W( i
.platform_data = &da850_evm_tl_leds_pdata,7 k. _! q, d% o8 q6 R7 Q& F7 T' R
.release = led_dev_release," n; B7 f7 t! R' G* S3 j
}" q/ `& h$ C5 m6 `
};
2 Y; @5 Z. _4 D9 e3 U1 i
1 a: R7 k! s( ]$ ustatic int __init led_platform_init(void)
9 h2 M! j; Q/ [0 k) a, ?5 |{0 S: c" d, V D+ q8 b! [
int ret;7 z! s3 J+ A- L @
#if 0
3 S0 ~4 e* }7 F+ t- n ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 l3 ~* v' k/ x' s% i3 G9 I8 o7 R if (ret)
4 ?) N& t8 F) P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 X3 h' q% k! E: ^" \ s% N& Z3 m- U "%d\n", ret);
- P5 P5 a. g1 \- y" {7 q#endif; |% O. }: f# q& f2 J
ret = platform_device_register(&da850_evm_tl_leds_device);) ^9 m8 b1 |9 N g
if (ret)5 Z+ S) u; M+ g+ Z4 p
pr_warning("Could not register som GPIO expander LEDS");
; A) X5 z6 n, {) d, X else
# d+ n5 M$ y4 P2 e- r9 l& b. g( R printk(KERN_INFO "LED register sucessful!\n");
6 w- a! f. T9 Z. s: f5 j
# d h( b8 H/ E* W( [. z$ o# { return ret;' ~. `& a' j/ p
}
6 a. Z# {' t3 z- @ ?' I8 E9 `1 A7 k/ p. i5 y8 Z c; M2 ?' A
static void __exit led_platform_exit(void)
. D, U& }$ O( \4 l- `) b' F3 o{
+ n# o5 z/ r6 V$ `& K" B" b platform_device_unregister(&da850_evm_tl_leds_device);
& G t) I8 s6 S1 N( B" Q/ n$ Y1 L
printk(KERN_INFO "LED unregister!\n");
+ x# M, ~: o, f$ o9 G2 D}
+ f# D8 P1 n6 Q7 M3 H( x8 V% A3 |& f/ ~. j+ ^4 o
module_init(led_platform_init);
+ x# n: }& ?9 A5 g. m/ fmodule_exit(led_platform_exit);
2 O2 z: E- m: U1 `" L0 \. l3 m# O, u F& i) M7 E/ \
MODULE_DESCRIPTION("Led platform driver");5 D. u; Z) ?" O; f# W
MODULE_AUTHOR("Tronlong");. {% x( l; B2 b s
MODULE_LICENSE("GPL");
8 s" m: J b3 s# ^" F, G
" G. D5 A1 G- O( {) a1 E |
|