|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& A" V4 H; @8 d8 y5 L( d4 D
#include <linux/init.h>
4 `! v d8 }1 T' Y0 n#include <linux/module.h>
* s- o( |# F- j7 Q#include <linux/kernel.h>
l. c b! i5 ]/ y7 C j/ ~0 U7 R5 N#include <linux/types.h>
' E1 x4 e" {: T9 S: ~#include <linux/gpio.h>( K. f% r& @/ t, D
#include <linux/leds.h>
7 Q' d( J$ O$ `# T1 L#include <linux/platform_device.h>3 @) X" @# e/ f& O0 K, K. h( W
' h- t, L2 S( C: I
#include <asm/mach-types.h>+ s4 b. C# z+ K
#include <asm/mach/arch.h>* I% Z9 k4 N' {/ m+ K
#include <mach/da8xx.h>
" O H& X1 t* E- ?2 j- \0 `) U#include <mach/mux.h>
; k1 w5 N( k% v* ~& \) S# X) X7 l- r2 Z' _$ Y9 Q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ l& e5 B' F; v# U, n2 ^" Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 d& \) p8 [6 y' C; b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ V! [% W7 J* G#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; y: B [1 M" l- g9 y# Q5 F& l8 t4 @2 H( E, Y8 [
/* assign the tl som board LED-GPIOs*// @' I/ H# v" c, J M7 o& p9 B# y
static const short da850_evm_tl_user_led_pins[] = {$ ~. v \& u8 g5 }( x" ^7 X, S
/* These pins are definition at <mach/mux.h> file */, r6 \- {# s3 F) Z0 c1 n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 e7 G& D. [1 c" Z; f -1
4 f" k ]% x# H) w* l};/ L8 ?: j$ D3 S; f$ ]: X6 }
: t' L m; A* H( E3 B1 g/ _* |static struct gpio_led da850_evm_tl_leds[] = {
; t! }: k2 X X! E {0 L6 e3 g4 b1 [4 r8 Y+ Q
.active_low = 0,/ B! H0 L6 C9 Z. f' Q
.gpio = DA850_USER_LED0,$ z% K! _1 R5 d: ^) y% T! u- p
.name = "user_led0",
4 j& S. j# Q6 A& J; w$ ^! ?, d .default_trigger = "default-on",1 e5 `0 X5 R7 `- O3 B3 x* K
},
6 D( K, X) N9 [) H4 _1 r {5 N4 y) Q1 E2 [# N8 v9 {# ^3 {
.active_low = 0,) c+ @: r4 f6 ]- t* `: u0 ^
.gpio = DA850_USER_LED1,
. M! A' ]8 r; t3 _$ @. ~8 f3 S .name = "user_led1",
2 @* _0 ?- z" g; z# k- p0 O .default_trigger = "default-on",5 T1 d9 {% _! N w4 I! H
},- I3 \8 `' Q; E6 W* [
{
3 x5 O6 X% L" x) t .active_low = 0,
6 }+ M' q5 e$ F @ .gpio = DA850_USER_LED2,3 v4 h7 x5 O% Z- C" f2 F o
.name = "user_led2",
7 z" e4 z4 p6 _/ Y1 ?/ u9 g .default_trigger = "default-on",' d0 E, e7 X6 m! E, \- G
},
7 W R; O( [' E: O8 }* _! e {9 `' w7 r8 d0 U1 r3 F$ ^" r
.active_low = 0,
6 z2 D' g! x# X" S .gpio = DA850_USER_LED3,7 Z; Q8 f9 c: [# G& k
.name = "user_led3",
+ C0 ~3 o& G6 D/ z0 P .default_trigger = "default-on",
( ?0 L' {; K" C% Y/ A* g },& ^" M, p8 V$ I. n
};6 j# R5 D' S; M1 s" h5 o- y1 R
7 y5 x( \- n d, z+ [static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: Q& c$ ?" l Z- |4 x2 B x/ H .leds = da850_evm_tl_leds,! T* \. \. y, n6 k R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" x0 ~. C) J$ d, c* Q; j2 U8 g8 R};
2 {* h5 G M3 k0 I
$ c/ C* N1 g \' c: Astatic void led_dev_release(struct device *dev)
2 R! t8 s6 _# a$ W{# H/ v8 [/ `4 [# C
};
5 b& l# d8 V1 N- H0 ` t* U4 k. w" A5 Y0 M
static struct platform_device da850_evm_tl_leds_device = {2 j& H7 X* n' C& x4 Z
.name = "leds-gpio",2 C+ @8 [; K& f1 P5 j) t) Z
.id = 1,
) i# ^( {+ h7 y9 V .dev = {, T+ q9 Z! b! i p. g
.platform_data = &da850_evm_tl_leds_pdata, {3 y0 l/ X* ?$ ~8 }' s3 C$ Y
.release = led_dev_release,
8 \$ |$ S2 i, r% M- h. D7 h) ` }
0 y J$ A& h, F' @% N2 f5 Z1 Z" ~5 T, f, O}; g0 k0 P w& [3 t( z& \6 O
2 P0 {. J- L( } J. [& _: O. H0 wstatic int __init led_platform_init(void)$ @) E+ V1 p2 T( x& w
{6 [; i2 @3 n! J! k" r
int ret;
% K% J" o- R+ A, V2 s5 X- }#if 0/ U; Z6 G K' Z3 c Y/ X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 l4 h i' i; R; o1 i9 I
if (ret)
2 r! S; s' h* }/ g. b6 J% i7 o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# A" ]5 e: Q9 a" c6 b! g "%d\n", ret);
) T' A3 f6 P: \4 t#endif+ J) Q% C) w2 z5 o; O
ret = platform_device_register(&da850_evm_tl_leds_device);+ ?0 ~: v3 M0 h
if (ret)8 a5 l/ l u4 p
pr_warning("Could not register som GPIO expander LEDS");7 R- w P" `6 @. f; C* n
else1 Z f4 J2 ~" V: V+ ]" o
printk(KERN_INFO "LED register sucessful!\n");
, ?3 i3 V3 H, [( f. f4 V9 K
! E- V5 |+ m' U$ W$ J6 g4 b return ret;
9 B$ w; f5 x+ Y0 u G/ v* {" z}! Z; A. q, @8 r# o. C# ^
( K0 a- B/ G5 ~( {0 `8 p% [3 ?- ?static void __exit led_platform_exit(void)- u& J4 e6 E- l4 B( D A% U
{
% C$ U+ {2 d \ platform_device_unregister(&da850_evm_tl_leds_device);7 }! V# p0 H" b& j6 g1 x* @3 {! s
6 d& Z) d- b0 h- _ printk(KERN_INFO "LED unregister!\n");
" `) B% @. X& t, `8 w* k! Q}* ~0 y# J4 w3 J- q2 o
, _6 A" J$ V& o; n2 k: V2 v5 Hmodule_init(led_platform_init);1 z: Q" ?' o9 t+ e7 I/ C9 a
module_exit(led_platform_exit);
+ `) X3 s3 @/ x7 z8 T# ]0 c9 s
" D. g: l, }. E9 nMODULE_DESCRIPTION("Led platform driver");; [" H2 `% }, W- l
MODULE_AUTHOR("Tronlong");; J* v1 h, _# q
MODULE_LICENSE("GPL");% W" g t9 M J3 L Y/ X
3 v6 V+ b: F1 ]5 ?0 T$ n# L
|
|