|
求大神给下面的程序做注解,请稍详细些,谢谢。& {% W, { Z2 W8 Y8 @* N
#include <linux/init.h>' i4 d/ ~( }" E+ @
#include <linux/module.h>0 i+ }* H1 [9 Z+ s& } J
#include <linux/kernel.h>" L9 F$ D; E+ o+ h0 p
#include <linux/types.h># {2 I _& Z% l# d, R
#include <linux/gpio.h>
1 Y+ l6 g: P/ s0 [ G/ |# q#include <linux/leds.h>
% P2 Z$ B) D9 r0 T% Y, g- ^! |#include <linux/platform_device.h>! @( K( c' Q8 X* ?7 h# k
1 c' W5 ^# ]. c% I: f! P) z1 d
#include <asm/mach-types.h>9 r; ~, j$ n" H: ~4 x
#include <asm/mach/arch.h>
2 L( [1 s A# }+ @( ^#include <mach/da8xx.h>
+ Q6 a+ I- K. V1 E+ ], h* q#include <mach/mux.h>
4 O1 @) _6 @: T! ?+ R2 Q' i4 m- k
: h- h( Z+ w2 d8 b( ]! ]#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# b+ C) m) Y( \. s# H, f$ q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 D4 D+ t! [ y7 r) a# o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 |/ i. O" T1 |( U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 z* F& T- F3 h( p' ]1 F* c& F/ \0 O( X- @' U2 c
/* assign the tl som board LED-GPIOs*/
3 V9 G. p# p! I# D& istatic const short da850_evm_tl_user_led_pins[] = {
l A1 ?0 F: ` /* These pins are definition at <mach/mux.h> file */3 B2 L% g/ J6 h7 \( ]4 [% P6 M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! E# v0 R3 G+ p, @3 [- Y$ o
-1
" T) S" C3 X. X A0 G* e7 e};) ^. ?! H$ u* r7 m2 a
9 }8 c% P- s8 k Ostatic struct gpio_led da850_evm_tl_leds[] = {
# h/ L# V6 [* F% Y+ Z {4 B+ X/ d* ^4 g! z
.active_low = 0,; I6 t) o- ~; S" u [
.gpio = DA850_USER_LED0,8 u9 O. ?9 R$ J' s/ | Z
.name = "user_led0",
3 F# R: Q& u. @2 ~: h. m* _ .default_trigger = "default-on",% Y3 ? p9 h- v# T* e3 H
},
; C2 ^8 _* j) h! A% {- k0 k7 f {
& r+ t9 w& P8 n: c' \) l6 z .active_low = 0, Z# Q, Z$ S4 H. U0 s
.gpio = DA850_USER_LED1,
+ c! A8 K) I: Q .name = "user_led1",
8 x G1 T# @# n, }9 C .default_trigger = "default-on",
, r) E4 g4 ^( J },9 c) F$ O# C" N) c8 B# F% v5 [
{1 \. R2 i q+ x+ `/ Q8 n. I
.active_low = 0,
3 L1 n& d; _0 @4 h .gpio = DA850_USER_LED2,
- K$ M" s' l& \9 g( b- y .name = "user_led2",! o* a" q/ Z' f9 D
.default_trigger = "default-on",3 M8 O) ?# D# v9 R" F
},
t* n" f% J0 c/ S: g. J {
d& W5 k; N. y' y# P .active_low = 0,
+ N( k* t: t' r% Y( V: U .gpio = DA850_USER_LED3,
/ W8 A% q. M1 ^. z" X- s8 M .name = "user_led3",
+ w5 {# N+ A3 u$ z4 n .default_trigger = "default-on",
" G2 C! J6 T) |# N2 A) u8 c' l; Y* C# P0 \ },
; I: U2 h+ t" B0 l6 r: v};( b1 I% \6 P, E; K7 C# {/ s
- ^; q/ W- Y- Z% w. F/ m; r6 j; ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ `% U4 t5 [2 r; Z- l. R .leds = da850_evm_tl_leds,
' p o1 W( r4 q8 D; Z k .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* [; B2 E" O' n% L! D};
% g C( ~! h$ ~. }; T9 H
/ U* s# o T3 d) ^, bstatic void led_dev_release(struct device *dev): G1 k% H, y" n# x# L
{
& @ y, G5 `( V$ \# v9 h5 q};
4 b) b* m4 n$ ^: r" E$ ^' W
# ]) f, r1 J; M3 H+ G' K9 w* P3 Estatic struct platform_device da850_evm_tl_leds_device = {/ i8 }/ A; U$ R4 a
.name = "leds-gpio",; F" R3 B, ^+ J1 O* i X/ F
.id = 1,6 s# B% V- G% U# G
.dev = {/ I: Y5 N+ }/ ]* B8 V1 m( Z
.platform_data = &da850_evm_tl_leds_pdata,
% k( B) w( {% I5 ^; |$ X- _3 | .release = led_dev_release,
a, d; L0 j! m% m7 t- W0 [ }' t* b: B; b+ j! d: F- D, {
};2 S+ H$ j4 d4 \# P8 e# X8 t
7 H7 L5 V/ C# o0 Z1 `$ k# ?static int __init led_platform_init(void)
3 H+ m' T8 ^; D6 d{
1 [! B; t3 m# `6 @, w& v int ret;
: R% ]1 ?# G! Q- S8 [#if 0) i! U" c/ m) {+ J4 O0 u, [
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 W0 N+ q. I/ R- y+ y
if (ret)
& c; R8 T( P) T( b" {' b! t, Q7 K( G pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ A$ I+ G: Z! V/ f
"%d\n", ret);6 U w1 d. | j4 S& D# N/ @
#endif+ _2 o: p( N( V
ret = platform_device_register(&da850_evm_tl_leds_device);
: n# B H5 O: P if (ret)9 g" V4 I( E1 S$ _
pr_warning("Could not register som GPIO expander LEDS");; h5 z5 j/ }5 {) e3 Z
else/ \) P( b* f- B% S, _) q
printk(KERN_INFO "LED register sucessful!\n");+ G" N3 B) _' C6 V. C! C
/ p& r. y5 s6 y5 V3 y3 Z
return ret;
* p/ S' D/ b: N% Q0 t}8 u! y, |; I* ^. o9 C
7 h; C6 T( b y
static void __exit led_platform_exit(void)+ z) O" [0 j4 D& c5 J
{
/ m) z2 J7 E- s% T$ W! J platform_device_unregister(&da850_evm_tl_leds_device);; U0 g* X, K" @/ ]' n3 l
/ i( | h% W$ p, T% T printk(KERN_INFO "LED unregister!\n");3 M2 J9 X; s. @$ X& c4 i8 y% O
}
6 a4 o* B- p: U/ v
8 m8 S! z6 v. l; Mmodule_init(led_platform_init);
) ~0 s8 m. e2 @8 f( {3 `module_exit(led_platform_exit);
9 [' `# x) L) n8 L; `7 F2 \2 | A5 |3 ~6 x: X5 ]0 W p+ d
MODULE_DESCRIPTION("Led platform driver");
4 f, s/ d. t! BMODULE_AUTHOR("Tronlong");
2 y! _% I- H C" u' `# T$ p; A' k& iMODULE_LICENSE("GPL");
7 H$ ?' y7 _. l) C O" g( ?8 f# h# m* g0 X8 }" ?8 c
|
|