|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 o+ l8 \1 f2 c5 U* N' l% e#include <linux/init.h>( {8 C k/ t; E# j
#include <linux/module.h>
7 A1 y! A3 L3 x/ ?9 R#include <linux/kernel.h># `& b3 e8 N( I: S
#include <linux/types.h>
, w4 Z# h0 x8 m& ?' x$ E#include <linux/gpio.h># U0 W& J; p" G2 t8 L9 }
#include <linux/leds.h>
2 S3 S, V4 I# S" [#include <linux/platform_device.h>
# P7 \* j! O0 O- ^
+ f3 |* }" ?: {) {$ Z$ Y#include <asm/mach-types.h>5 y6 s* S; q$ }8 j5 _% x
#include <asm/mach/arch.h>& z7 l7 N5 }- ]
#include <mach/da8xx.h>
- D0 v+ `/ L4 e7 W" j, U#include <mach/mux.h>/ T" ~2 r2 |! d& N% N
6 c0 K/ O8 @3 P. Z0 o/ N
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# b6 ^9 ~3 G& |" n8 N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 p; V6 j' |5 M9 w( M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; Q4 U# a! e% Y* ^. a) p#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: W8 m% @! i! f$ \5 J6 M# |" b" }5 b6 i/ e2 \. E+ i
/* assign the tl som board LED-GPIOs*/
8 y+ R% y, R2 r8 H' c& M5 pstatic const short da850_evm_tl_user_led_pins[] = {
0 ^+ a+ ~' W7 n3 x% C. O# z+ c /* These pins are definition at <mach/mux.h> file */; z; g/ m1 `$ O: \- Z2 R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% a3 G) M6 d; F. F# D; p6 y
-1
( }" U3 v; B5 s* i4 g y, r};( H: q- s5 F% a1 u4 P. a0 j
2 G5 a) W; o1 v( r/ ^7 N
static struct gpio_led da850_evm_tl_leds[] = {
! e7 X1 v2 H; W {
/ i# Z8 d2 E! } .active_low = 0,
. ~' ?! v8 a, I6 o" y& I& f .gpio = DA850_USER_LED0,1 f3 Z$ t9 b9 w- A: U3 j% K
.name = "user_led0",
* I9 o3 ^4 e* ~7 X .default_trigger = "default-on",8 K! @9 M6 s: |4 ?+ A3 S- V
},$ s1 l/ Q0 ^+ r! a+ v
{1 N& \" J6 c/ |( o5 `; Y* p
.active_low = 0,
6 Q8 W" ?, S2 n7 T .gpio = DA850_USER_LED1,' B( G& U+ d: x/ {
.name = "user_led1",2 |0 r7 q( B) f$ e4 Z
.default_trigger = "default-on",
; `) T! T( ~9 u },
- Y+ ~, V& V, O8 y' Z- Q {. W+ l* z' N( C% [
.active_low = 0,
4 g& g# E6 h! [$ u: o; t% S `5 X .gpio = DA850_USER_LED2,# A0 E' |; ?3 i* H8 g+ Y4 {: r
.name = "user_led2",6 `4 N5 `1 A8 @
.default_trigger = "default-on",* `$ `: T; G: r! z1 p
},) _! l" h& ~4 V8 ^/ y% K9 i% K; Z
{$ S+ x) ?0 \, e
.active_low = 0,
% T7 W0 P; u: F2 V; X, v& F9 f; |7 p .gpio = DA850_USER_LED3,
" E6 s& o' r9 q; A* j4 K$ P .name = "user_led3",0 S& m6 z' B6 x0 G$ P
.default_trigger = "default-on",* l, G1 l Z8 `9 m% r
},7 u4 c4 r. m- b% y7 Q
};
5 w) E8 n0 g( {2 o( e8 S/ S/ s* Y- h) m* z' ^1 t( P% j* C5 Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { F: m4 d4 o' x7 G5 {5 ]
.leds = da850_evm_tl_leds,
" y) F* ?3 W, l9 P; V$ t3 _7 K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) n% l+ T" D! C A3 O};: ]7 t1 M' R; r# t' i) h) y Q( X* W
8 Q+ H4 @% @5 Y
static void led_dev_release(struct device *dev)9 ^5 w9 N' i$ w/ K# D5 X7 s
{
% d) M" [3 Z- k};% T, r s, b2 X0 j* G
! D+ R9 e0 X# l+ U
static struct platform_device da850_evm_tl_leds_device = {( @) L& ^) \' Y7 W: Q, N
.name = "leds-gpio",
# e+ Z$ ~$ B0 g, e0 N( S! s& ? .id = 1,5 K0 |1 n+ E) ]" I. m
.dev = {3 y( ?3 G( r' ~9 M' X+ Y# X K
.platform_data = &da850_evm_tl_leds_pdata,
' K) o% \$ w' P) z& J1 N .release = led_dev_release,# B8 G$ S- J. L. Q0 v& o) ~- V
}
3 ^/ y2 @; j Q8 I};! O N# x. z; f/ b' T& k1 {/ V
$ M) J: d- e( ?# F# R0 i3 Bstatic int __init led_platform_init(void)
) M7 r6 n& \% H7 g; d4 v2 n3 ~5 t{
; {. T- R* w8 r' l$ V7 V9 }: C int ret; H" ]/ Y2 P( N. G; a) z
#if 0# A$ p% I5 I8 J v5 n5 Y7 f7 R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. g: C7 j" D' ^3 C, _1 u if (ret)$ L! m# A" L- s. I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& E- \1 e+ D2 r6 }' z2 I; O
"%d\n", ret);1 d8 @( y8 V8 K4 p
#endif
" G( r9 ?/ [! y9 U+ T5 w ret = platform_device_register(&da850_evm_tl_leds_device);/ ~: d* b9 t& [3 _- s1 u: `; H& d& f
if (ret)+ Q8 l9 V9 ]; h; Z' g9 M6 n
pr_warning("Could not register som GPIO expander LEDS");) C* m9 J+ m% G5 p: N0 a4 d
else
8 |8 A* q% b" Q v. f printk(KERN_INFO "LED register sucessful!\n");. U/ x3 b: y% W' g8 c1 x
# T0 Z4 S B. D5 y0 F0 T) r9 H$ G0 I3 x
return ret;
4 P8 E' A( \. r' p# n9 b}
9 z* {$ w3 z1 h `- W4 o: z9 h; v9 {
static void __exit led_platform_exit(void)6 K) y- _- u4 q0 ~6 r8 F# X( Y' x
{2 h8 [& D f) O* x5 D* ?) M" S; \
platform_device_unregister(&da850_evm_tl_leds_device);
5 H1 Z5 q* n: I/ _$ L( X. g
: @; N6 O$ e* C printk(KERN_INFO "LED unregister!\n");1 n S$ w8 {6 f% e4 v7 B6 S* i# Q
}
/ ^2 P% u' v! l( N! f2 o$ s, O% n7 x0 k& U7 n6 g
module_init(led_platform_init);
4 x R* ]6 b4 Z: ^9 g9 |module_exit(led_platform_exit);7 ~% U% S6 E8 R- C
q: P0 s5 q0 p2 N: k4 {2 c1 A4 }
MODULE_DESCRIPTION("Led platform driver");6 G& \# h, [! T1 O2 a4 D
MODULE_AUTHOR("Tronlong");. h% h+ m9 k; a f( w
MODULE_LICENSE("GPL");. W) I1 e* }0 h
/ E* t, W- F! s/ ~+ F
|
|