|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" @' _4 c5 s3 h" u
#include <linux/init.h>
9 [0 U* F+ n4 P7 _4 k& R. x0 R+ _#include <linux/module.h>
0 F9 c0 @, \1 V) @3 T% b#include <linux/kernel.h>: H* C3 N) S" b
#include <linux/types.h>
1 |0 W/ P4 y9 P* H#include <linux/gpio.h>% y: g$ G) k3 |- ^6 {
#include <linux/leds.h>( J1 b5 v' R; C Q
#include <linux/platform_device.h>4 f4 R! l5 Y5 O! \* D5 |& V
- D3 N& q/ F$ a% G6 N1 D- [' `
#include <asm/mach-types.h>6 z4 D; S7 c7 S3 Q s7 d
#include <asm/mach/arch.h>/ e1 @- y; \5 C/ w& n3 q( ?1 \
#include <mach/da8xx.h># h/ b0 C# s" x' t
#include <mach/mux.h>
$ `1 a1 C$ `$ G# L& e4 W3 q+ q
1 T, H9 W; z) `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* _- z: y* q, F( d/ {$ D S+ {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! A! K9 g1 R; y* _6 l
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 k, ]/ g$ P+ _0 }5 D/ l
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ r8 }" F: {2 y3 O; h, m8 J9 Q2 t- H! \; A4 j
/* assign the tl som board LED-GPIOs*/( t; s; B6 J* \: G/ S
static const short da850_evm_tl_user_led_pins[] = {, O; r" }/ L) h) H! H; r: |! X
/* These pins are definition at <mach/mux.h> file */
$ [4 s, M& Z; h2 X7 u: \" ~- W DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 O: o* y7 h' p7 ] -1: c$ u- V3 r. _* J- }4 Z7 A
};
9 I& |& Q- j# V) W) m4 Q4 k" j8 y' Z7 y
static struct gpio_led da850_evm_tl_leds[] = {
4 [0 S6 g. w; l+ |: M$ j8 O( ? {1 _# Y' M8 q- o6 h( M9 z
.active_low = 0,1 _8 a, o; l4 N% v. z$ u
.gpio = DA850_USER_LED0,
* U: j; X1 }3 L% | .name = "user_led0",
p3 q8 ]% U) k; p1 k9 g .default_trigger = "default-on",4 w, t7 k0 y, m+ ~# j$ ^# R5 t
},% |- O# _$ O# K) j: t. @) l3 r1 v
{+ l, E9 G% x9 l3 D- `* W1 h
.active_low = 0,
# L v1 m2 x D# a .gpio = DA850_USER_LED1,
+ }: j2 s: `2 V6 w) a& n& l6 h .name = "user_led1",+ x P' v' X% a( R
.default_trigger = "default-on",2 v& v( W! b+ B+ x
},7 w3 X7 d* r, N/ n. M! K, h
{
8 j5 q4 c) l7 a" G) p' f# A .active_low = 0,
2 P) i2 I$ A% {+ w0 J3 S7 j .gpio = DA850_USER_LED2," N3 y& |& f4 P( z2 m8 g
.name = "user_led2",% g- u2 N; L/ G+ j" N' M
.default_trigger = "default-on",
& h o9 Z2 q) K/ v },( R% x1 g5 b. T; j. K' H/ F5 I
{
0 v8 r: n5 Z$ i- _+ Y J .active_low = 0,
) W$ k: z: H7 I .gpio = DA850_USER_LED3,! m& j; C/ ^5 e9 C: B$ Z* A$ q; \5 V$ ~
.name = "user_led3",
- V) h" j6 P: ]1 d2 U .default_trigger = "default-on",
8 s$ X: W0 j R2 g5 ? },, V- P% B9 N W
};( H% w6 b7 c& u- f' ?
& \4 U, n& o5 n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* |7 \7 I5 m! B .leds = da850_evm_tl_leds,# v5 A4 _% R% ?8 B; s; |" j# g
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( c- B0 J) f1 d; @};2 ]3 X3 o0 R, `
7 P8 L5 X; j& E0 ^- R) h
static void led_dev_release(struct device *dev)
# J& H( V: H9 a2 k- Z3 U) m) r2 ^{
) g; r& w1 j; B' n9 T};- `1 l( J# c( K( _5 @+ X$ F. y
6 m- @. G) l& a7 _
static struct platform_device da850_evm_tl_leds_device = {
9 Y' e2 I: Q7 T' S& m# R .name = "leds-gpio",
" J; d# r9 U* { `% u+ A# }$ _9 Q .id = 1,
* d) Y5 s H0 f+ k: ?7 S2 K4 S4 \ .dev = {
6 ^! J8 Y$ k# Z. Y3 o9 A$ y9 a .platform_data = &da850_evm_tl_leds_pdata,( s$ \8 x- ^ \5 [, t6 j# W8 [
.release = led_dev_release,
: z6 @: N% y- ~7 E6 R3 r$ b' u7 m }" x, K2 k1 l1 l) u5 i& X$ L* O h
};
. t$ w8 ~- T3 j( u4 C& F
, c6 C; r! ^- H: nstatic int __init led_platform_init(void)0 V6 E3 ^# ~) L5 T8 w0 O' \% y
{
5 o+ J" f. y7 a5 p* H int ret;
/ z: e7 E7 Z: P$ D! a' R#if 0% t$ A" A# x8 s
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. f; Z8 y0 D' Y! L1 e if (ret)3 ]* W1 `: c5 g7 V: I/ U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" [7 }; U8 c# P6 x( t" z- { "%d\n", ret);- C3 ^, H4 {. u& Z
#endif# J0 E8 J. v j
ret = platform_device_register(&da850_evm_tl_leds_device);
' r# E+ V* c8 g7 ^4 N. y- ` if (ret)' E& [3 F1 x1 x9 q
pr_warning("Could not register som GPIO expander LEDS");
" l/ O+ g& ^) ], ]1 D3 C) O else3 M' q6 G$ n% u" _0 {- f
printk(KERN_INFO "LED register sucessful!\n");% ~! [/ u* N1 |; R
9 q9 K1 W& d" [. G return ret;+ w1 b3 [5 ?- R' U$ U# n# q
}
+ l5 C& a! J+ F' w2 U& z4 `6 y `$ H+ z0 w: J% m. M8 f
static void __exit led_platform_exit(void)
$ O3 Z/ S8 l1 o{
& k6 t) g3 }8 l4 Z+ O6 |4 ?& y% A: g platform_device_unregister(&da850_evm_tl_leds_device);
8 U1 u* y! w# U. L$ d
6 @/ @0 S* ]- ~3 l printk(KERN_INFO "LED unregister!\n");
! [1 ^4 y0 q1 m5 L. d( M}
7 b& }) k- \4 w \8 R! _. v" w* l' b5 z+ G' ?
module_init(led_platform_init);* B Y: {9 v+ _* O! U' \; W& a
module_exit(led_platform_exit);3 x l* O3 i4 V. ]6 n" y# `& b G% T
; z0 b7 Z% F" S5 n
MODULE_DESCRIPTION("Led platform driver");
& o8 [5 n7 P' A3 {- DMODULE_AUTHOR("Tronlong");9 u4 k/ t, B e( @2 ]
MODULE_LICENSE("GPL");
& A4 \/ r. p$ j. R* {8 e2 \7 w" o% }3 e7 u3 E- P
|
|