|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ @: Y7 d" E8 K' E- s# i4 M. {#include <linux/init.h>' A9 T9 M8 i* z# T# W b- a# R
#include <linux/module.h># V* k' F0 I G
#include <linux/kernel.h>) m# c8 m" a0 b, F- c6 t, y
#include <linux/types.h># Q7 H0 U7 s! Q# w& t3 {
#include <linux/gpio.h>6 r# j8 d/ S& F. } `1 W
#include <linux/leds.h>
1 @' {& M9 b6 Z#include <linux/platform_device.h>
( z4 H' c+ `' c! v; S* I* P0 W, W" A3 v: Q2 L i/ s
#include <asm/mach-types.h>
$ h! e) ^; b+ b k#include <asm/mach/arch.h>1 b. D# W9 d* H: k. u& C; Z
#include <mach/da8xx.h>3 z- j6 k( \9 k% G# [4 w7 i
#include <mach/mux.h>8 P' ]3 Q' F) H% d- H" b
+ l# y* u9 e4 O7 N$ E' G# d" u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); ?5 u" Z9 I) v, S1 j& m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) i) b1 B- p3 e7 f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 x& ~5 a; |/ Z# B, r3 z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) g% J, C& h$ C5 K; c
5 \1 Y6 Y( o# h- `' y Y: D! ~8 h
/* assign the tl som board LED-GPIOs*/# E! y7 H, X) n! ?6 r$ d5 ~4 U
static const short da850_evm_tl_user_led_pins[] = { l- m6 G0 I7 ?: Z
/* These pins are definition at <mach/mux.h> file */
9 z) \8 _/ Q5 i: _5 V0 u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) ?* Y: Z( m3 D6 S. U$ N5 N
-1
/ ]$ l" I$ u! Q% X0 X$ K' _};3 b( m$ t6 z$ F& d, M, c s
4 v3 A4 Q1 V) H' C9 D% b& Xstatic struct gpio_led da850_evm_tl_leds[] = {+ k+ }4 R* @- v, @
{1 v+ N& A" O6 [$ h- z
.active_low = 0,) e$ r% j# m J* X
.gpio = DA850_USER_LED0, N$ \5 W* q9 \" v" c( j
.name = "user_led0",
, e2 T6 I E5 e: C: l" ?7 ?( D .default_trigger = "default-on",
" Z& `: b. T1 y' y$ A },
9 Q$ S" c$ M% R# R( ?+ v) g5 R/ e {
( b6 ^9 O" A6 Z2 Y7 P" h5 e .active_low = 0,( z& d# j/ p, G* E7 f
.gpio = DA850_USER_LED1,
5 Z/ ^5 r, v; Z6 S: \6 n, g6 i .name = "user_led1",3 g- }8 `* T2 d9 T1 S
.default_trigger = "default-on",
: {& s+ L0 @7 ]) Y& W },! s$ M E+ G5 d3 C+ w
{
6 @$ J: Q5 Z/ @8 r8 ?: c3 p .active_low = 0,
C! Z6 x7 r8 R0 F5 `$ J+ n5 X .gpio = DA850_USER_LED2,- L% {" F7 H7 l4 B' f
.name = "user_led2",
; c& S3 w+ W2 m/ s5 R+ Z s3 R .default_trigger = "default-on",0 I0 g$ ]! ^8 N! C* U& H$ r& v
},
! X2 ?) [5 m5 V _ {
! z5 B3 T1 H+ f/ Y* y .active_low = 0,
7 H. T% O ~3 C8 X) _ .gpio = DA850_USER_LED3,
`8 B: z1 e, ?1 ] .name = "user_led3",
$ o- _7 n' z4 B+ G7 U% R' z .default_trigger = "default-on",
, o) ~% K W) ~+ d+ k$ `1 l; d },
! @" ?" g6 J: @$ u& F; Y6 p};
' q- d( M4 \$ Q( Y$ U- F2 I& J
% g2 G" O. x4 G( F. mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 o' ^+ B# }- W8 {, q5 ]2 K% O8 D
.leds = da850_evm_tl_leds,
+ o0 Q! I& h' f .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ z v3 I% z1 w5 T
};
( D. Q: P! g! M& @
" y3 S/ ^! ~# ]; J ~# gstatic void led_dev_release(struct device *dev)2 C: F3 X. \. I5 y6 G! }
{- B% e3 p& a! i: @+ _
};
0 P) P5 N3 f# q) h p
# Z# A* u- Z. k Z b0 Hstatic struct platform_device da850_evm_tl_leds_device = {2 t. w4 Y. Z" U$ F( G8 Q% J
.name = "leds-gpio",# J$ J' o0 L! C" M* Y# q: v
.id = 1,! V! x- ~8 y* F8 L5 _
.dev = {4 k D& A" S+ Q% B6 r8 `! K
.platform_data = &da850_evm_tl_leds_pdata,
9 H/ y7 S: i4 I7 @ .release = led_dev_release,
6 U1 d9 U# [2 h' _ }: r5 A# w1 Z4 a1 V
};
- K$ X' f7 m, O; K
5 ?! Z; ]0 o- G0 F; x estatic int __init led_platform_init(void)
9 C0 G5 U) S. P5 B6 M& ^7 I7 d{
/ q+ [1 k m/ A int ret;
1 d5 o6 ^ Y# j$ @( }7 P#if 0
$ Y- V5 m: y% S" k ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: C1 H3 a7 Z8 f, J
if (ret)9 V3 P+ {5 D7 A
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 z+ r% E: g) l. y) } M. | "%d\n", ret);! Q/ _# L3 O7 b- d6 K8 P
#endif4 `5 a$ W3 i+ {3 d
ret = platform_device_register(&da850_evm_tl_leds_device);; n B' y! u$ f: _5 L7 p+ L5 E; Q$ P
if (ret)3 u0 [/ |8 l) L+ J
pr_warning("Could not register som GPIO expander LEDS");' }+ H3 W* g( D; Q/ b
else' @0 k: R( Z" O5 F! |3 O$ K) H
printk(KERN_INFO "LED register sucessful!\n");! f1 R- h; A/ J, s
2 V" H; Q# D w) {1 ~4 _8 X% J
return ret;. \: Y2 U: A8 r# @. f: T
}
# s/ V \ T. Q9 D6 F) U" _. Z @. f
/ a2 y& F+ Y$ y$ ?1 }+ `static void __exit led_platform_exit(void)
0 S; n" M- i! k{5 q. y, j: s. N, S
platform_device_unregister(&da850_evm_tl_leds_device);
8 y1 D& K( N8 j3 }* k3 y
* D0 h1 D% B5 C9 ` printk(KERN_INFO "LED unregister!\n");: k1 j8 A$ {+ ] s
}
" a3 I5 p1 l6 J8 e2 A2 G% b |; T9 V
module_init(led_platform_init);1 {5 J' i$ T' W# \+ g
module_exit(led_platform_exit);
( }3 p: h" n7 N2 q/ u' c x0 h5 B8 u! N
& O" ?( H$ J% aMODULE_DESCRIPTION("Led platform driver");
2 {& h3 X4 [0 C8 A+ kMODULE_AUTHOR("Tronlong");! f. t6 i; _# D' Q
MODULE_LICENSE("GPL");
7 s3 ?/ n( j G" ~& I t2 Y3 p
; e" m: d, {6 o& G; Y" `$ J7 g4 v |
|