|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# m1 T* ?! s9 E9 d, p#include <linux/init.h>
$ f3 z/ [% @" t* i* X; Y9 C0 i#include <linux/module.h>: ?7 R/ w9 d9 Z! \5 k
#include <linux/kernel.h>/ q% A: x7 T0 O
#include <linux/types.h>, W. M2 S7 f8 o: |' } }1 [2 y
#include <linux/gpio.h>. G* y) _/ v% e
#include <linux/leds.h>/ N0 p9 x @* z( Y1 \. }
#include <linux/platform_device.h>
. c0 y/ O3 r/ H2 i' p7 ? B2 m) ~3 K* R8 T+ D1 K* R1 O' U( R5 o ~
#include <asm/mach-types.h>5 R, v8 L) }( e' B: [
#include <asm/mach/arch.h>6 |4 x2 [5 ?/ F: l1 x2 F1 k
#include <mach/da8xx.h>
$ }, Y7 s+ t* D3 @# v4 B. @5 I0 W#include <mach/mux.h>) V; M5 `* m# j# e4 Q
' d6 R8 X# A. U6 w: H: i6 P3 R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# q; a- n8 ]8 a* m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 v& h+ `- O' K6 _: \" t1 n" x3 n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), j( J8 a* F; C& y: B
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ v& \2 y6 w: Q# v
8 V6 @( Q. c; L* i5 I" H* T/* assign the tl som board LED-GPIOs*/. f8 X6 N& @9 ^/ C; Z
static const short da850_evm_tl_user_led_pins[] = {
1 k2 X J4 c$ o /* These pins are definition at <mach/mux.h> file */
- D6 E; ^6 n# g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 }& P" M! F" c# C1 B
-1
7 k+ D0 F6 n" ?, s: M8 k! e. z};8 X; w+ X( B9 W. S: U! v. @" m4 g# M5 u1 X
6 H1 r1 `6 E4 l7 i" |/ p3 G) _, n# E
static struct gpio_led da850_evm_tl_leds[] = {! Y/ P) L0 ]! X( V/ G' {
{( t" s) [ L( G8 Z+ L
.active_low = 0,
% B2 ^* e* W9 m! i .gpio = DA850_USER_LED0,9 d* X4 o ~& g/ g
.name = "user_led0",7 [. j4 w, h' }& h% l
.default_trigger = "default-on",, C9 g0 C! S# |1 T
},
7 i. L$ o7 q9 S! ?% B {: L' U3 s: S+ E p8 n h
.active_low = 0,5 I$ p- I5 h8 J- I U# ~: r
.gpio = DA850_USER_LED1,7 p# z# Z; @. t! v, l3 S8 ]
.name = "user_led1",
9 P+ ?1 N. h" B/ W .default_trigger = "default-on",
. B( z# v- N2 V },5 \ R3 h7 `2 q* l" R
{+ ~: V U3 l. m4 O6 p
.active_low = 0,) B& j. i; p4 D( b4 f; B/ q
.gpio = DA850_USER_LED2,0 ?9 J& y- L8 p. T
.name = "user_led2",
; C, ^- z- u) s .default_trigger = "default-on",) S0 ~0 s) s) p( P6 U0 h7 i
},
% m$ ^6 G" n7 g) B' M; x& F! M {" a/ M& _3 ^* t. D7 z
.active_low = 0,$ W0 [* x S) q
.gpio = DA850_USER_LED3,& U& f J/ d1 o# E+ A6 y2 @+ Y
.name = "user_led3",
' b7 P$ W$ w3 H) k$ L .default_trigger = "default-on",8 d! q, j7 D$ c7 U% m
},
$ p+ }6 K N; I) l1 ^ y4 z/ U};! \9 k5 B5 A1 C1 E' [
8 Z A) h- A2 k0 t) n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( W( H- G0 n( v9 B% d, n( e .leds = da850_evm_tl_leds,
3 K1 m/ p0 F: h! q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ Q/ f. H4 _' L8 o( i};
, _! S3 z( \: W7 S" ^, f$ V [5 C3 x
static void led_dev_release(struct device *dev)
' j/ f5 l- ]) u1 ]+ d{" y; b" H l7 }, t7 q
};) `5 \ F) o; W6 h' k" Q! J
- U9 s6 m, L8 E O4 J2 N) X6 m
static struct platform_device da850_evm_tl_leds_device = {8 `+ H) l/ w9 P& o' Y
.name = "leds-gpio",
9 g: c# t1 p( u6 x .id = 1," q! r- H E' n) A( p5 p& {6 o3 |! a
.dev = {
7 D4 z9 |3 |8 d1 z @ .platform_data = &da850_evm_tl_leds_pdata,: t. D" O( Y7 `$ ^- Q$ }
.release = led_dev_release,
) o3 @8 d& H6 M" G; P" ^ }# A( i* s% ?3 _ u. V3 Z
};
# Y5 g, [4 \8 x/ `, n u1 [2 z2 T+ h; Q6 F- J1 N$ g4 i
static int __init led_platform_init(void) ], g' V8 X: ^
{% l4 @1 g b" z& r/ e
int ret;
7 Q$ c; c v: F+ A#if 0
2 A. \( r% @- |+ o }6 x ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: y4 i/ L3 n0 ~1 x
if (ret)
0 y2 A5 K- I5 O8 ]& w- [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 P9 k9 ]0 Q ^8 G- L+ ], B- V "%d\n", ret);# b" w0 Z, ?' S) x
#endif. J* w' ?) S4 ?. ?
ret = platform_device_register(&da850_evm_tl_leds_device);! \" x9 e2 L+ P' [2 n4 U
if (ret)9 J. F, r. U+ A5 Y
pr_warning("Could not register som GPIO expander LEDS");& P: w/ I6 Q( i
else
, v4 h5 o- ]# y N% T/ g3 s printk(KERN_INFO "LED register sucessful!\n");
8 M% J% m. s9 |: c9 v4 Y8 t4 ^, R3 o
& B# k5 n& Y# R' K$ U return ret;: \, K7 V: g, f7 Y% f
}. Z* h5 L9 j9 D* S
+ B! P+ a1 |. Y/ j4 mstatic void __exit led_platform_exit(void). u$ _6 m g: b; u8 w5 K. C
{) o) n7 F, _* P6 K
platform_device_unregister(&da850_evm_tl_leds_device);
$ B6 H C8 j" b; Y5 B
. v7 c- q8 z% t' ]2 } printk(KERN_INFO "LED unregister!\n"); M/ T# s. {: b5 K: c8 ]
}) j$ y3 v/ }9 ~6 d( U g
) ^3 J: A& H. Y# z9 b0 rmodule_init(led_platform_init);
* E& r- M; _1 w5 @7 Y R% qmodule_exit(led_platform_exit);5 e1 |% y9 X$ G! A# _& h5 P
9 @& a# P, v8 D0 P+ z/ Q* j/ NMODULE_DESCRIPTION("Led platform driver");
5 o9 K8 k+ L! ? h* E1 oMODULE_AUTHOR("Tronlong");, Z q7 b& ~2 m
MODULE_LICENSE("GPL");* u; r. T9 }8 H& H
% ]0 C: b% l$ `; \ F" b' H- _
|
|