|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) I( |/ d! n9 J* Y) J6 ^$ H
#include <linux/init.h>
8 D+ s, L d0 [4 T9 ~#include <linux/module.h>7 g/ Q2 U; w; H; z) }0 A
#include <linux/kernel.h>) ^5 H$ a5 m v; P
#include <linux/types.h>& }# u; } ~$ [! p# s/ p
#include <linux/gpio.h>3 q3 c( T0 A7 k2 _8 ~- \4 ]- w9 f; `
#include <linux/leds.h>8 U6 N9 J) \$ j9 C
#include <linux/platform_device.h>
: ^" a+ O" r7 u& W- z0 d, A
- I4 U4 f# f0 g! s#include <asm/mach-types.h>
" F5 @7 d* `) G$ ^: W& i" W#include <asm/mach/arch.h>
6 v q, U4 ~) D8 s! e5 y#include <mach/da8xx.h>
& s) C* _- Y) F#include <mach/mux.h>& i3 a" R: M1 X, b$ g' l
; ?2 V# T( e% J. m9 o. U1 @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; V2 V$ m4 } T0 E2 ^#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). A0 Y0 j4 |% ?" w+ E4 r; A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( ~ l( } x7 u/ I
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( m$ f g+ O1 h( F+ k! j. A
. f: `( B0 F4 S* v3 A/* assign the tl som board LED-GPIOs*/
# Y) G* K/ l' t. U* a+ O0 jstatic const short da850_evm_tl_user_led_pins[] = {
& h! U5 }0 S* @8 q4 h3 ? /* These pins are definition at <mach/mux.h> file */; f+ n8 M# G- x$ [& x+ @/ G1 u9 w% l/ X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 h) f5 n* S& B$ T2 `4 ]2 w0 A3 z -1' l \/ H' U3 X- f$ h1 l( I
};
+ F% H; j1 l- {( L h
/ e% q6 |- M+ `" p' j/ ystatic struct gpio_led da850_evm_tl_leds[] = {) W+ x4 Q1 I3 x% Y+ v' n
{
# z) y1 @' H2 E- P, S .active_low = 0,
, [. G& s( \& a5 N .gpio = DA850_USER_LED0,
) |. N7 A& @% d: X' {% j .name = "user_led0",
. @, T' k g" C' ?6 o h* N .default_trigger = "default-on",
1 |2 ]# e) _" v7 B# N b* w },+ Q! q* {8 ]3 _, M3 H( h+ |7 N
{9 j7 g% T- q+ p8 A
.active_low = 0,
6 V! A2 h8 t- T9 ?9 S1 M; c* C8 _0 ~/ ? .gpio = DA850_USER_LED1,
3 i% G; D; m# q( U: N* Z .name = "user_led1",
6 |! k! F5 k$ t .default_trigger = "default-on",
7 |, x# Y; y0 E8 y },
9 ^( A4 X) R3 |4 J2 a5 e- P {& b6 u Q9 ?: g `: K
.active_low = 0,
& a7 Y9 t" ~' x4 }# s- i b' i .gpio = DA850_USER_LED2,$ n {: A0 }# I9 v3 E- v
.name = "user_led2",
1 u# _9 k% {3 P& \6 Y! F .default_trigger = "default-on",
( r+ T A& k1 |- \- j },
% T7 Y! `% q. n- w) |0 F {7 O1 l D4 Z& W( K# i
.active_low = 0,8 f$ s, f" {* B6 Q: O" Y, z
.gpio = DA850_USER_LED3,
; l& C% n# _) K .name = "user_led3",
; U; k+ Q" i' G% W+ k .default_trigger = "default-on",
4 s q" T, `2 P) s7 c% Y0 N7 P$ j },
- x% e& p; z/ a# s};8 I& C: c; I3 k# Q" o" ~
: {% J/ ~3 a- l$ a6 F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 M) }2 t- R- t% j6 y/ ? .leds = da850_evm_tl_leds,5 h% R" j5 z8 S- X i
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),. _1 K1 C" P, }0 }" d6 w3 N
};1 O5 _1 T- _" o( S! Q
0 Y( J0 L! I" t S8 J; c7 dstatic void led_dev_release(struct device *dev)
9 ~" s# K4 _2 [+ Z$ e; \0 U{/ T$ C, T9 \7 D
};% \: E# d9 d, Y: T9 L' R
% Z$ ~1 g3 Q9 s. ^/ ?% Estatic struct platform_device da850_evm_tl_leds_device = {
# Z% m6 o$ R! P8 ~; W. W$ D- X .name = "leds-gpio",
1 h: v0 V$ Z8 w& [, ]( L7 J& S# ` .id = 1, J' W9 `8 E- V6 X, ]
.dev = {% O( }* w6 r x S9 X( }
.platform_data = &da850_evm_tl_leds_pdata,
" L( a: O. {/ K% R: w& g& _ .release = led_dev_release,
3 ~/ c* Y% w, R) T }
# c' Q" u: H5 z};$ C% ^" c1 {/ {. w3 y2 ~: |
+ D7 W0 W {5 ?4 A- P, ?
static int __init led_platform_init(void)
& o9 x4 R! Z" P! Z! q{
7 C! g' T+ j( g8 ~; Z- D int ret;+ x' d5 R% B: y0 f1 R! r
#if 0. G. x; Y/ R9 k+ I9 |4 e+ ?
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 l0 o4 D _! |- X0 N6 v# p
if (ret)
5 ]& B" G s: a J9 m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
D- T# U7 h1 w) Z "%d\n", ret);; N- r* T; R" P4 Y U4 @
#endif
; `3 K) m f5 z" B$ Q5 s ret = platform_device_register(&da850_evm_tl_leds_device);; E2 B4 R. G5 q+ \, n
if (ret)$ E7 F B. [4 i: t. T3 Z
pr_warning("Could not register som GPIO expander LEDS");# ~8 J( V0 V& \- M7 h' n! ]
else
/ _/ V+ m% H. l- E" ]5 j( q( \5 G printk(KERN_INFO "LED register sucessful!\n");
! j( [8 I. l I& N$ H" U0 c% B3 k: ^8 X; H+ j' m& B% r. o; k
return ret;* [) L' R8 b0 R, h1 c3 \
}: ~8 Z6 ]. `+ X* y1 }
5 F) I. L% f9 P) @& g. h! ]static void __exit led_platform_exit(void)
3 |( P0 f# }$ \7 o{
, ?" C) s+ }4 E7 {# ^" H platform_device_unregister(&da850_evm_tl_leds_device);# N6 d' N7 B7 `2 q$ v
0 d9 i) i$ ^& N7 H& o printk(KERN_INFO "LED unregister!\n");
. Z' G3 A$ s5 Z}% O) l4 p7 z5 a9 O# s
, m; b5 I4 a( g
module_init(led_platform_init);
& X% ^, x& G0 d$ l. emodule_exit(led_platform_exit);7 ~2 ], {6 T( E* o% c
+ T8 E4 S2 b ?0 g) ?) i
MODULE_DESCRIPTION("Led platform driver");
. ~3 a! ?1 n# F6 p) i* UMODULE_AUTHOR("Tronlong"); i" b& C& Y) b) N& V2 k& c
MODULE_LICENSE("GPL");( n w9 H! ]3 }6 e8 s% K% r
7 x& D% ^" r) C* ?/ F8 [ |
|