|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ [# ?5 C% o6 ~
#include <linux/init.h>
4 W8 V% x. u% k8 U& E#include <linux/module.h>
* l r* r2 j2 d% r' V* S8 V- w; ]# p; {#include <linux/kernel.h>7 D. Z9 X9 d" T/ _* e
#include <linux/types.h>
$ Y: k; {, \) a- _( X w! C#include <linux/gpio.h>+ z$ a! M( t: {! s# |5 e1 s
#include <linux/leds.h>
7 s' G2 Z5 b4 j4 F2 B#include <linux/platform_device.h>
- H- N- ]8 @* m) d' f0 X4 w4 c
9 U6 f' Z% U! u/ a1 q$ I#include <asm/mach-types.h>/ Y2 n# ~4 w7 n/ x( _
#include <asm/mach/arch.h>
" H, H6 ?) e7 ]- I) O5 q#include <mach/da8xx.h>
; b- R. E$ x2 G# e v#include <mach/mux.h>, q. X+ H/ t. s( S% c
% G. z" Z% m6 {6 ]+ @7 I P9 M5 S5 M#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" U9 g" k5 w+ {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
{1 A- V, a( W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ |1 Q, A2 }# L3 l+ w T' z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 i) _3 [3 ^7 F8 Q/ [2 }
! G# w; \" }9 j& k2 C/* assign the tl som board LED-GPIOs*/5 z5 x" A6 X+ j; n
static const short da850_evm_tl_user_led_pins[] = {' G% A4 x- i4 [+ k F
/* These pins are definition at <mach/mux.h> file */
2 \" `$ @, n+ A- N DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( r/ x. u7 O6 K7 Z8 w
-1
! U8 g" x0 M2 A) G; r};0 O- T/ g4 W; E
8 y% N$ E4 D7 U$ s6 ?- _$ y* T3 hstatic struct gpio_led da850_evm_tl_leds[] = {9 E$ U* p6 ?+ }% u7 S* m3 X& j3 _; c
{
$ x! a/ z S+ U; E: m( U .active_low = 0,
; |, h' M* }/ Q+ w .gpio = DA850_USER_LED0,3 ^4 O3 J" p' v) m6 x4 ^) ~
.name = "user_led0",
2 z9 L9 q; N9 r* T .default_trigger = "default-on",4 J. U0 c- Q3 Y+ Y
},
" `$ G4 W4 R+ I4 S; P4 |0 J/ | {# _+ z% ^; r( {( c0 q2 G
.active_low = 0,+ J6 W" |; J: S& @2 x$ a
.gpio = DA850_USER_LED1,
; q2 N# z3 B; o' a* r6 `9 f% I- `" W .name = "user_led1",( \" L! q! a( M1 H$ x6 B
.default_trigger = "default-on",
* ~; W+ P, b2 I; o },) c1 K& ^. g4 j) U
{
( O6 P6 q& J8 x, m2 r/ { .active_low = 0,# |% H& W4 @- `
.gpio = DA850_USER_LED2,6 P, r0 D' Y8 K# @8 g0 ]
.name = "user_led2",
' r; v) [) V0 S! l! T .default_trigger = "default-on",. m8 S0 k" F% t* t9 O8 ]9 o
},
& T$ r. D& u! H- F, _. O ]+ E {6 M+ o) u/ c+ a$ M
.active_low = 0,
( P8 _" t- ?9 I7 ^ .gpio = DA850_USER_LED3,
7 y1 p6 P0 b- S .name = "user_led3",
, W' ?* [6 E1 C/ B! R .default_trigger = "default-on",/ b. U3 P6 ]% T0 v
},
7 r2 I9 ^6 G! }};7 _# \+ T: e l7 t. }! T
( P9 [) P5 u& i6 G! k3 \) `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" A1 F) b' y ]2 R2 x
.leds = da850_evm_tl_leds,
4 _* H1 g# {: N A0 c! a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) h: @0 H$ j& H0 D; J};
( H* l# h! E1 c: d5 A$ m
3 Y) }6 V8 J8 Q0 x7 ]0 Mstatic void led_dev_release(struct device *dev)
& r& g7 @. {( g{
$ e, n" Z. _* \: v4 V- l) o% q};9 c( [( V# M/ E8 o3 F
, x# m; f2 }$ y0 L3 c( Q. ]
static struct platform_device da850_evm_tl_leds_device = {
a; U0 {2 G& X .name = "leds-gpio",
& f6 x$ E2 K8 r7 T; @) |) I: I* P .id = 1,! v f, M, {" g! N5 M# K" J) z
.dev = {
7 O* m3 r. b4 X: P* W- W .platform_data = &da850_evm_tl_leds_pdata,
" e5 @! Q% l4 G. n. q4 L .release = led_dev_release,
/ K' n' }# G$ c( W/ {+ ] }
9 T: ^$ s1 `5 W! G6 Z. w C1 { T};
% D6 a5 v) J( d3 _% p/ V) N& }% Z. G/ z! ?
static int __init led_platform_init(void)
& x" @0 e$ w: @{
& {6 V) r( M% U/ w* U1 ^6 c" \ int ret;
- P: Z6 t9 Y& U4 Q#if 0
; B+ e: j% {; c3 w ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% @- S. [- `0 e X$ I5 q if (ret)- R! \( {- ~4 { G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :": B6 j4 N6 X! v, v. ^6 m% ?; e1 G
"%d\n", ret);
+ }$ H5 V' {6 v; B1 R4 |, s#endif& T/ W" h4 Q) }* c/ e$ Q+ B& p
ret = platform_device_register(&da850_evm_tl_leds_device);
; B: T/ }# t, v/ _ P* k9 { if (ret)
+ e' i [. @" H! I% a3 o7 J pr_warning("Could not register som GPIO expander LEDS");% q6 C- i4 `0 o7 K6 G& ?
else
+ p" z2 M/ z. _( ~: { printk(KERN_INFO "LED register sucessful!\n");
5 c% W8 b$ |8 G( J* ?
0 m6 H- s& `: Q, {1 w/ T return ret;
_% [6 J+ u4 ]# `}2 l/ l& \5 o) t7 T* G
6 X: V: P9 A$ @static void __exit led_platform_exit(void)
5 f4 c$ L- ?+ n; ]4 G7 ~2 v6 X5 F4 D{& I K. ?! g! \! J) }
platform_device_unregister(&da850_evm_tl_leds_device);
6 ?; [9 O3 a! ~$ k
4 v8 X: W) f( U. s* O printk(KERN_INFO "LED unregister!\n");; t7 j$ f# e; I: x9 ?3 m
}
5 a6 T+ Z3 L, Q- f* u. w: H& b I. w* R6 h
module_init(led_platform_init);( i4 }. |" }- \0 m; g1 C+ M' i
module_exit(led_platform_exit);
5 J6 @, x0 q/ W1 s/ ~) t0 A! u) M5 X) S- E3 F, o
MODULE_DESCRIPTION("Led platform driver");# O9 x) M7 Z% [
MODULE_AUTHOR("Tronlong");& N# l4 F6 N$ V t ?/ a9 u; M6 O
MODULE_LICENSE("GPL");
$ q* E7 A' o0 Q% m" {5 \7 ^
' T4 ?: W' v8 [( J7 P* l3 T |
|