|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! m w9 M" E$ m+ P/ K
#include <linux/init.h>
: O% \! ]3 s+ M4 k) D0 H# ^2 f+ F1 e#include <linux/module.h>/ t: A, n% f$ }1 s
#include <linux/kernel.h>" E8 K3 u2 h7 h: P
#include <linux/types.h>
C j& _" g% Q- R2 G#include <linux/gpio.h>0 ?* |( R5 u! q5 o# ? @5 G P
#include <linux/leds.h>& n) | m% S8 ^7 B
#include <linux/platform_device.h>
7 e3 n; {- p) J9 D" z2 W
# E7 N# T6 x8 t8 O* s#include <asm/mach-types.h>& U0 u: P- k i" ]
#include <asm/mach/arch.h>3 [3 T5 n" r ?3 }5 U$ |
#include <mach/da8xx.h>
6 V6 y [2 v+ e- o- Y! w% X Z#include <mach/mux.h>
& M0 {! L; s2 r( o6 V* Q+ h) B, e2 H" t( g( h4 L
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! }: H9 T3 S: J8 y% U
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 T4 t4 N7 S8 F: Z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 d; z4 \* L' Y# L
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# B2 [- V9 \- ] i0 @
$ h' Y4 Q! |2 G2 Y+ ]- [; |! w/* assign the tl som board LED-GPIOs*/0 S2 @# @0 V* r; `# p. a- s7 ~
static const short da850_evm_tl_user_led_pins[] = {
3 f5 U' i7 ?- Z( V! N8 N. Q /* These pins are definition at <mach/mux.h> file */
% q+ {/ A1 N% } DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: A9 [: Q2 J' a -1
; W, f9 _1 j2 w$ D};8 t6 i" G; x" X1 T0 m
g8 ^$ X" i% d
static struct gpio_led da850_evm_tl_leds[] = {
+ K4 M0 l& W$ m3 s2 p& a& { {
3 T# h7 }) }0 ?" x .active_low = 0,9 x/ `" B, K7 Y" d6 K
.gpio = DA850_USER_LED0,- i- d2 a U6 i ^' Q9 E9 d
.name = "user_led0",
6 _5 R5 S7 t3 H/ C .default_trigger = "default-on",
5 i l& Y" ~0 |; L' ]$ q },
; W4 Z9 U! K" `1 _ {* s2 Z- c* l, w1 ?
.active_low = 0,
2 x3 ?6 H- E0 F' X# p( F .gpio = DA850_USER_LED1,: d/ c" X7 l1 d# d7 P. {
.name = "user_led1", f1 G( h' F7 x1 G% w8 Z
.default_trigger = "default-on",, @6 Q4 v$ p% p8 D- a
},6 I! A' g7 U) A# Q/ Z
{
, X7 ^3 D3 q9 E6 E6 y/ Q .active_low = 0,/ E) |' x/ V8 f% o+ ?; _7 D
.gpio = DA850_USER_LED2,
# J: r8 s' m0 q" z1 h .name = "user_led2",. x$ w' p+ X" J; B+ a6 x
.default_trigger = "default-on",4 c: d- P8 P% o( n
},
5 U6 `! E" \% d# Q2 w0 E {3 L/ m5 w7 t s' ~) D% C# L
.active_low = 0,9 |. z( F5 r- p# ]3 B" Y( `8 o
.gpio = DA850_USER_LED3,3 `3 d/ [% v" `
.name = "user_led3",
1 e. ]( Z+ \1 J- W8 n$ m( t; M .default_trigger = "default-on",, h$ j% B+ B7 s# @7 V( W/ k2 J% Z( b
}," ?5 z4 w6 q! {, J1 F! l7 B
};
& z6 g Q! j u! c8 L% P6 A& x4 L5 `
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# C& q/ `' C! y+ v .leds = da850_evm_tl_leds,
8 L+ M b c. ]6 l, X d2 b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 B& M+ \ o7 p* Z0 n1 n2 l
};* o: v* l: s! f2 |( L! B j
6 W# k6 X8 p9 C" p3 \) t
static void led_dev_release(struct device *dev)# g, d% b8 @( c
{+ E! O* E, o. F/ a% ~/ Q8 D
};6 v. a+ S7 X4 @: d0 W- E
2 Z7 _! X5 T) d7 d5 u/ O
static struct platform_device da850_evm_tl_leds_device = {
" a# c4 z8 S5 z* {4 E- X5 I .name = "leds-gpio",. t# v. Z7 O. Z4 S3 D
.id = 1,
3 L! _9 p; i5 v3 b" s .dev = {+ T0 E4 f' z& r* D
.platform_data = &da850_evm_tl_leds_pdata,
4 Q' n+ P, P: A' E .release = led_dev_release,
3 V& X. d o" M. T% Y/ [! E) i, p* k }- G# G4 [" s; e; ~! z# U9 k
};% `8 D+ m- c( Y* M: E
& h* D- y* {; d5 D+ D% y
static int __init led_platform_init(void)
) s3 `# r, N. F, U+ A3 ?{# A& S! ]/ M0 L' S( j0 A* e
int ret; S0 F5 O" I& \
#if 07 f* q \! e5 D1 _: U' N" s- r8 ^
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 B" j2 X" r2 A6 \$ i8 c( u% G if (ret)
+ u. `! H! j/ [& L8 Y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* G) u f5 F8 t* G "%d\n", ret); Q+ w3 S5 Y/ B- l; T
#endif2 n& v( [; d7 T2 o7 r0 D
ret = platform_device_register(&da850_evm_tl_leds_device);8 o) t9 b R' q3 ]# w
if (ret)3 o% v, w7 r& G. j. L7 w
pr_warning("Could not register som GPIO expander LEDS");% |0 Z F4 ? P9 v
else5 s3 F+ g) S- w" T8 d
printk(KERN_INFO "LED register sucessful!\n");$ s+ B# {) u3 S/ S
' a( q: E+ @ E# Q& x$ J return ret;
9 l$ B- U; R% @}# H0 [- P0 l2 Q. @
+ Y" u6 O7 `1 x% v2 ]static void __exit led_platform_exit(void)
" Q& {7 Z. k; a( K4 Q. d1 B8 }{$ M+ e2 Q s0 ~- @! r
platform_device_unregister(&da850_evm_tl_leds_device); t3 S2 E2 P; B+ D, V* y3 e" D
! C& R [, {& \6 J0 k printk(KERN_INFO "LED unregister!\n");
- b+ ^- l4 v8 x `; W- U- `} n( g- e, [* t8 g- t
5 d3 h) z! B0 v: P! q! u+ Mmodule_init(led_platform_init);1 o# y8 W7 r( `$ L' w/ }
module_exit(led_platform_exit);
3 T* ~! W8 p- j& W
( r3 K5 V3 V' A6 y3 oMODULE_DESCRIPTION("Led platform driver");
3 @+ a( I5 c4 \MODULE_AUTHOR("Tronlong"); m! }( ^8 N& E+ q
MODULE_LICENSE("GPL");
. P4 d; ~6 h. z4 d) @
; ^3 _% Y9 C! } |
|