|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 P6 P R+ ]% O; g6 `* W. Q( `#include <linux/init.h>
; v" Q4 u) i3 Z6 e" I/ [#include <linux/module.h>
7 e. U2 ^% W3 `% Z0 b/ X3 e+ ?#include <linux/kernel.h>
- g& }' M, W# V$ @# G#include <linux/types.h>4 @2 F/ j* @/ Y0 j2 W
#include <linux/gpio.h>6 x0 f. W! B3 F) `0 A, x
#include <linux/leds.h>/ r5 s) u/ `: z7 E4 ~
#include <linux/platform_device.h>
! V, o7 R9 Z& ?' ` F+ V+ g- j7 G
#include <asm/mach-types.h>! P/ l/ U+ p# M/ k% ^' Y4 _
#include <asm/mach/arch.h>
- ~1 L& Z5 M) C+ e$ c$ I2 [#include <mach/da8xx.h>- W5 }! h0 I# B6 c! i
#include <mach/mux.h>8 C4 x2 {) }7 b J ]2 o5 F* ?# Q
& q7 `* L a% H$ [; u#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 _/ n- J4 c- i! t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( ?* s, Q9 A' C6 q' ~, ?* Q1 ]
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. E6 U& ?& F/ c; |" M5 [#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) P8 n. Y9 x! A; U4 V! S' R5 ], @
# R: e6 B3 d- T% g) N
/* assign the tl som board LED-GPIOs*/* t, q+ Y; C; m4 E0 O* q
static const short da850_evm_tl_user_led_pins[] = {! U/ E, Z* @* D2 D
/* These pins are definition at <mach/mux.h> file */9 R" J; V/ {$ E6 b" H% E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: q' B0 I4 q; ` -1
- i1 M8 @, `% g9 c& r$ O};
; k2 H6 B3 s) ?; B7 O- U4 V7 K; y2 X. @3 u5 D7 l* \
static struct gpio_led da850_evm_tl_leds[] = {7 i' p' O0 F; S* r: j* w1 N
{& }$ N& ?5 M5 ]; p U; U
.active_low = 0,6 b5 a% R$ I4 D7 J1 j8 b1 ?" m
.gpio = DA850_USER_LED0,
4 {8 u) { E" e* p3 ?. H0 X .name = "user_led0",
! U9 Q5 U( m! V, e .default_trigger = "default-on",
8 Z* j! k4 T8 Q+ G a& f: K2 h },* P) Q9 U& Y; @/ C: c
{9 Z5 e6 `. K4 Y$ p
.active_low = 0,5 w5 m1 l" e; {/ O
.gpio = DA850_USER_LED1, p4 M2 n7 t* f) j! `9 s @
.name = "user_led1",; N; N+ s# v+ u& Q+ v. x6 Z
.default_trigger = "default-on",3 ]# N" C! @. h/ v2 s% g
},5 }) j2 e: E. w: |
{
) P' ^; ^" d$ U .active_low = 0,
' U5 F! I% z" |) l" Z" J .gpio = DA850_USER_LED2,; y* k* i4 |& i- F3 Z
.name = "user_led2",0 |! I2 v4 A& P0 Z6 j* L$ Y( s
.default_trigger = "default-on",- _8 ^4 R0 F: {' T) G
},
; f( D; P, E0 n4 v& I8 A0 L {* Q" H1 f0 B* M1 ?! B; r
.active_low = 0,- T( q6 o5 a1 i2 y* K6 e3 E
.gpio = DA850_USER_LED3,' z- G5 e; ?+ b: n, U6 q3 w% Y7 ?
.name = "user_led3",# q& E1 x: l; _" a
.default_trigger = "default-on",7 n2 v& Q9 R2 u" U$ g! [" I- x
},
% X0 w1 P3 b5 f7 N4 T};
! s2 c4 Z% f! |( m" b4 o5 g) W, o
6 e: P5 A2 [# v# {. Z$ ?4 ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. |" W' {. X) i0 [; Q8 G5 L .leds = da850_evm_tl_leds,4 \7 \6 n: l& o" r) ~5 a! n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* F6 K4 J s- A) v6 d6 p};8 `' Q6 x( d q$ c/ u
% o! A/ u2 _4 c: Jstatic void led_dev_release(struct device *dev)
1 M3 P7 X* Q4 q' ?; I{
' ]) \3 L: ]0 @( A: F- j/ E};& R8 G2 c( m) L: j! E( H' k _
/ ^) f1 ?/ k' d: B3 Xstatic struct platform_device da850_evm_tl_leds_device = {
, y+ e1 n. s% [( V7 u. [ .name = "leds-gpio",
, J6 Z1 @. L8 u. c .id = 1,
3 O& I$ d7 ^) e' m .dev = {
: D5 |! n# S5 I! N9 U4 j6 ]" N2 X0 A .platform_data = &da850_evm_tl_leds_pdata,! v( J6 k) Q; w' h8 @- g# o
.release = led_dev_release,
8 ~" l6 K5 W' b+ s }& k" j: w3 K t) }! k# l- ?
};& C$ N+ B, I0 |" C
# H9 S- `# ?% V$ e, r* r
static int __init led_platform_init(void)
: w% n# [5 s9 {' }& Y# t{2 H2 n! P- t! a1 A5 g
int ret;! z+ O& R# k0 t
#if 0% \) B+ @, g# e O9 h
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- G |6 ?0 n( W, G; O& P- D
if (ret)3 U& X. T: P! N; W* d0 ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; I3 l7 j& ?) S) |2 I' j
"%d\n", ret);
8 q- T4 k0 X. t: g1 [#endif4 p! i8 F% h" V
ret = platform_device_register(&da850_evm_tl_leds_device);2 e$ U6 O6 f& Y( R0 k/ C
if (ret): \9 J0 W- e& w: F O2 A
pr_warning("Could not register som GPIO expander LEDS");$ [' }3 f5 s- X. h: c1 R7 |7 k c$ }
else
7 Q& ~ u8 \0 u" J# J* x printk(KERN_INFO "LED register sucessful!\n");9 Q/ s% J1 `2 W; \
0 S) t) ~* k7 w+ J6 w6 h return ret;2 f" x( g% P5 m; l3 p
}: X( @7 V# N5 X/ p* x) y% f8 O
7 [, D7 A! c6 t' m8 J7 M: M5 W& x, t
static void __exit led_platform_exit(void)
2 i# d' D/ F) i" \; ^. g3 f3 j{
) V! s% @$ G! z8 V' r# g+ `! ` platform_device_unregister(&da850_evm_tl_leds_device);- n6 e" ]* h2 q( d1 L( x, k
% o; r w$ X& Z7 ~( T printk(KERN_INFO "LED unregister!\n");
2 l! \4 g- g; y}# N$ t% B% Y j
! u6 z& I6 ^5 A" r
module_init(led_platform_init);7 h l% V. L/ F) V/ M9 \' H
module_exit(led_platform_exit);- B0 U6 M4 Q5 o/ `9 L
! x4 K& h7 o" h4 PMODULE_DESCRIPTION("Led platform driver");
# {5 v$ A! [; Q7 N0 n, DMODULE_AUTHOR("Tronlong");; F S9 p7 M& g* p& {/ B5 X
MODULE_LICENSE("GPL");2 N% C# P# ?, O: x8 N1 B
; l C* Q1 D- ]$ G# M |
|