|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 h# @ K2 X# H0 j+ K* [3 h#include <linux/init.h>/ _1 F% j7 `' m+ ?
#include <linux/module.h>
; a/ s- m8 A3 G, E# T/ E#include <linux/kernel.h>
5 ^ B' a4 W5 v# y#include <linux/types.h>, }. V7 b) [9 _0 y" J; h
#include <linux/gpio.h>
. b8 ]7 N$ m5 g! K#include <linux/leds.h>7 |0 L# O4 G8 R o e; p9 |
#include <linux/platform_device.h>
# _% |* c4 w5 E# X5 }5 J$ w$ c
* ^4 [' ~" Z r1 d9 B/ Z. b: I0 ~#include <asm/mach-types.h>
2 u( j; ^# W9 H, @. a# U#include <asm/mach/arch.h>9 r! V1 _' y4 e6 T: {! l
#include <mach/da8xx.h>
) c: k( T/ B8 x6 S/ Z! U/ }#include <mach/mux.h>8 s4 B$ e9 q, o8 d# K
" W6 I% v2 e( Y$ @, T( C) I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# |' ?+ M# w: E- t M
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ t) |; q/ k& z, R" z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 |$ h3 n( Z+ L; Z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 Q' o, w8 f5 }, h1 k: X u6 m3 Q" H8 Z) v, i, a f
/* assign the tl som board LED-GPIOs*/6 C4 I! g2 A% K% Z1 ~
static const short da850_evm_tl_user_led_pins[] = {( Z X7 S+ ?5 Z$ S: j; O% m
/* These pins are definition at <mach/mux.h> file */" `/ Y. E5 j% Z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' {6 T2 r1 i7 G' b6 n0 O* ~5 n -1
( j" i$ |% V7 X% J$ U};
, e- g* [" V( H+ V* t+ _
5 Q4 c- Q; n B; Ostatic struct gpio_led da850_evm_tl_leds[] = {
; x$ c4 C5 \. e# k! Q" p {8 s" @& x1 I: ]* o) t F/ R
.active_low = 0,
: P! }+ E* P3 D7 L5 ^/ D4 C' E O- V+ k$ ` .gpio = DA850_USER_LED0,
/ c; o2 z( M& \4 E% I .name = "user_led0",- [) j- @7 [4 l8 Y" d6 |
.default_trigger = "default-on",
& B) B) g( R( a& j: D; B. w },) B1 e' A' |0 @# w4 S1 m8 Q
{" ?+ g& s8 u9 e1 t8 \
.active_low = 0,7 w( p# v+ k) e9 S; {0 R
.gpio = DA850_USER_LED1,
4 @3 r0 e* ?) a y; m+ B2 r6 L! g; a .name = "user_led1"," F) k+ _/ I4 W. y- c) f
.default_trigger = "default-on",& c* B( T6 i/ n
},
0 l5 M) f0 N N7 [ {
) f' g0 U. f) ?% T9 [; w; b q+ r .active_low = 0,
+ S" C% I7 L5 Y .gpio = DA850_USER_LED2,
1 p, K, y6 ?# E .name = "user_led2",
, Z( Z' F, e+ S1 F* s .default_trigger = "default-on",4 h7 \0 u- j( w9 M! s @/ f
},
- ? _: y. N" d+ L7 l {
% S2 S, ^, W8 V3 R+ U7 @ .active_low = 0,$ H7 M% P) H, [
.gpio = DA850_USER_LED3,0 K) o2 ~% f( q! A& ?4 S/ o
.name = "user_led3",$ D7 ~( |4 r" e. g
.default_trigger = "default-on",
% Z5 U: q9 R4 M },
9 u/ J* \: ]- q/ [7 i};$ b& t0 ?# \4 X. \
* h, v2 ~" D% M- Y* kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% i- S5 \& g7 [) | [* R8 V
.leds = da850_evm_tl_leds,0 D- E {! b3 e, r* E$ M6 T: W
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 s% b1 C% f6 o P9 [};2 y) T q4 ^( o, Q; W7 |! y6 Z* w! ?
" `6 Z* k3 X# D% X
static void led_dev_release(struct device *dev)3 r' N4 }; C2 l3 T# C6 U6 g
{* ?; j8 ~' N# ~* [% U
};
+ o9 E$ M, \ K) I
7 l0 G% p" c, J2 e# Nstatic struct platform_device da850_evm_tl_leds_device = {! S C/ f0 H/ H) j( X
.name = "leds-gpio",
, e- ?' J3 P5 Q# _9 h+ y .id = 1,
# y9 f# U- \6 V/ T: k .dev = {
y `; i$ C* M3 `4 L- L8 f .platform_data = &da850_evm_tl_leds_pdata,
a# l" ~$ E+ ]% c2 j0 y8 r .release = led_dev_release,2 E: }- N; [$ L' P: Z
}2 o- k N! X+ n8 Z# `
};
: Y, t6 E2 X7 ^3 Z1 v X5 d& e# y( ?/ O6 ]
static int __init led_platform_init(void)
0 _6 Q3 Y! [1 I{
8 V8 a: H$ K% y% M$ q int ret;0 {. k) e4 W& B# [$ T
#if 0
1 H' ?! f& o7 |! | ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' J& T. o: v3 z if (ret)
! L9 ~- `+ r# C6 K- `+ r: | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 U2 O$ u1 ?/ W "%d\n", ret);$ ~* Y% \0 i& h M# t
#endif& |$ @; ]; \, [) ]+ \
ret = platform_device_register(&da850_evm_tl_leds_device);: n4 {3 Y& e& @
if (ret)3 D9 t7 I p# J: O
pr_warning("Could not register som GPIO expander LEDS");
) P4 |6 k' z! \3 v4 s, H; [. q else
& ^. x1 @. b. F" {& P printk(KERN_INFO "LED register sucessful!\n");
! j# G1 R: H/ C6 o9 X5 P) H4 r+ D7 C
return ret;
- _3 b9 }# z/ c3 V' m}1 n; q5 ?7 ?( h- P7 U2 J, ]
6 }( B3 \. p7 P4 ], w. C9 gstatic void __exit led_platform_exit(void) O( f7 M* X8 [- L
{
+ @' |/ c* G5 V1 ` platform_device_unregister(&da850_evm_tl_leds_device);3 \& Z- T Z$ O
& ?, d) j3 Z' M# A2 G$ Z1 F! J printk(KERN_INFO "LED unregister!\n");4 J6 `) {6 m8 l- z/ A- C6 D8 T
}7 E7 [- [( f, _ m
0 n/ [) y3 I3 @+ s& {! @module_init(led_platform_init);6 Z! u1 N1 Q9 ]: S& |
module_exit(led_platform_exit);( s/ v& Q9 q9 f( z S0 g/ G8 K; k
* j$ L. _3 q6 OMODULE_DESCRIPTION("Led platform driver");
) k/ c" T, O% O3 z, ~; @' dMODULE_AUTHOR("Tronlong");
- H9 v' P: Q0 W: o; c- M$ t6 Y5 CMODULE_LICENSE("GPL");) B2 g3 O/ C1 p
% f$ k7 h1 @3 Z i% |, O$ U |
|