|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ N9 M. n3 w) K1 g/ l( M5 g#include <linux/init.h>
, N% t3 T8 J4 E/ A7 Z, }' N#include <linux/module.h>* F3 b: o8 C1 o `
#include <linux/kernel.h>
) P* |2 ~% d% B$ u! g, E#include <linux/types.h>
1 Q; i* H9 Q6 x( |1 J5 S#include <linux/gpio.h>
- u2 y$ Y' m9 f* v- b* d#include <linux/leds.h>
# U) q! r+ }8 X' {6 s1 Q' C#include <linux/platform_device.h>
. L9 H' [' ?4 _2 ?0 s* ?
q( F4 w! Y9 G- d( P# Q; E8 Z* S& y: B#include <asm/mach-types.h>% {4 G% H9 H0 G: a" }* j. O
#include <asm/mach/arch.h>
' n+ K3 C9 ~7 O& R: d0 g% b8 ^) ~#include <mach/da8xx.h>
0 D# |4 q+ l0 ]1 ]# ?' `#include <mach/mux.h> O# g$ D$ Y1 _- q1 o0 \4 N( z. n! Q% s
0 ]1 S6 v) F- I: H+ C, f! j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 V. u/ _# a9 E7 J9 V5 \; [
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) K) {, q) e, w* F; C#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 i9 T( {/ j4 V E" w8 V/ N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; G; c- S; Y5 |8 t+ E( J) A7 E r0 _ v( H
/* assign the tl som board LED-GPIOs*/9 b1 s! g, l" x0 D5 p2 p6 d6 t/ R* U
static const short da850_evm_tl_user_led_pins[] = {
$ g4 @+ K0 j! ?4 Q" ~ /* These pins are definition at <mach/mux.h> file */
) c0 }. D; }1 ]1 a' l/ L DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ m8 r' {% C0 g$ Z
-1$ X, B5 M5 K1 \7 ]: f
};! D8 V* } \1 G$ e& P$ f
' w% O- G' _ N! z2 G
static struct gpio_led da850_evm_tl_leds[] = {* ?, W+ y3 Z2 f0 W# |4 e
{
! u- J B' S1 g1 O; O1 @( f .active_low = 0,
$ \; R2 Z3 U" r0 Z" x6 y .gpio = DA850_USER_LED0,
' ?* q) {: n0 [5 v4 Z2 [ .name = "user_led0",
2 f" C: d) N& f .default_trigger = "default-on",
+ S) a8 K9 U6 Y& v0 b" ?& Y$ r },* y6 x: {4 V" z% v9 K" ^" r
{ R1 l& @: p. _/ c. a, F
.active_low = 0,
7 l6 D6 W: W! f9 s: G0 {0 L! L5 Z .gpio = DA850_USER_LED1,; Y8 {& E0 y% y* L5 N3 c
.name = "user_led1",( h: ?; t3 i! D' j. K
.default_trigger = "default-on",
- S; t& X+ ~3 S },9 ]/ t2 p7 h" |' k8 I; Z
{
7 d! ?% [% ?. X4 l .active_low = 0,. _! u: Z( U; b) d: q; ?
.gpio = DA850_USER_LED2,) g2 _0 w {, n- B3 W
.name = "user_led2",
: y* h) [' e m% C .default_trigger = "default-on",
1 n" Y. ?& K5 U. \ u8 y },
' V/ U6 D/ T* u1 | {
$ N7 o1 h0 E. W! i1 e2 g& q. Z0 e .active_low = 0,
# j0 X% s- B& m9 { .gpio = DA850_USER_LED3,! c1 y1 F- E v7 }$ D) n
.name = "user_led3",( H1 z4 o3 L; c' T) P8 D2 t' r1 o
.default_trigger = "default-on",
% y* `" b8 Z4 D; B },
n- b. F& R: T* Z5 _) [};8 a8 o% R6 D8 W8 |, E4 i
$ h4 \! D0 d4 I3 z: l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' q1 I; d1 V- s .leds = da850_evm_tl_leds,
) z0 B% Z; u2 C' o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) [$ |/ f N5 w5 T. @3 K) }. |
};/ l) }& @+ T. J
8 X; H. {4 S$ X/ X
static void led_dev_release(struct device *dev)
3 W! i' ^( i* v) P- z{
7 ?& c# R6 r* Q8 i};
. j3 ?! v* f2 K+ m* d
4 Z" P& T( m" u8 pstatic struct platform_device da850_evm_tl_leds_device = { ^2 E5 A5 r% F& H) j
.name = "leds-gpio",+ K3 T% E5 ~, y+ E5 i0 f& B
.id = 1,- M. [5 T2 T. \7 T4 T
.dev = {
' F* X. l9 k" |4 k& _5 x, A* l .platform_data = &da850_evm_tl_leds_pdata,
' Y2 {9 q# T. s, w5 @- N9 \ .release = led_dev_release,
2 Q6 s6 o) D7 q }. T1 b- O% c. S/ B1 K) O# A
};
+ q& K- T5 e: r0 }' h& a2 a! T: a4 E& p8 h- S- }5 L
static int __init led_platform_init(void)
4 I( q8 }: ~3 D$ O- ^. v# E+ Z{3 s: e% s3 m0 _) `+ g2 ]7 j- j
int ret;
, g5 L- @" A6 n; a. y#if 0
" Q, ?2 G# }, x$ q; Z* y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 y+ A) V& b$ x7 ?3 B2 T# S4 S j' A if (ret)( k) l, C- c) t/ l9 Y" F* E) E6 C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# y2 ]: X4 R: P' V
"%d\n", ret);
# Y( F) z: q" n1 c. z#endif) V V5 I: c5 R
ret = platform_device_register(&da850_evm_tl_leds_device);) M/ o! ^, g; v
if (ret)- E1 R- R+ s0 d7 e: B2 D
pr_warning("Could not register som GPIO expander LEDS");
- M6 w9 A" D+ \6 L0 U else
# A1 B3 `, t# v& x printk(KERN_INFO "LED register sucessful!\n");
* p8 d' I$ M. a, X) ]% l; q8 U) Z; O. w
return ret;9 n: e; d& K- J
}1 m9 T# r8 V2 n1 K E
, T/ d; w" W2 ^! ^: L) w& |+ S6 \static void __exit led_platform_exit(void)) Q4 E6 [4 p% n; B
{
' d3 y1 G& \3 T- S3 ^ platform_device_unregister(&da850_evm_tl_leds_device);+ I3 S+ Z8 \: \6 u9 A
: n: V1 S n% d( h4 M printk(KERN_INFO "LED unregister!\n");
$ W, R* a7 ^ |' Q}" C1 i" w! ]% d3 W' w2 P* n0 \
3 F; T! y" a8 n* J5 u
module_init(led_platform_init);0 S1 N0 t) i e
module_exit(led_platform_exit);
6 x, d' k% X; V
2 S! \5 |! W" T& q: cMODULE_DESCRIPTION("Led platform driver");; w6 i0 G' i7 G& y
MODULE_AUTHOR("Tronlong");
4 F! ` a d0 w: O8 EMODULE_LICENSE("GPL");
5 N! T' `5 P7 Z6 S+ P1 D1 e$ j/ j
|
|