|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 L3 x* i9 A0 J) f3 R8 M7 `
#include <linux/init.h>" _& G2 ]* x0 Z7 x2 Q- Y
#include <linux/module.h>+ [- w9 E6 D/ C% v5 }" D9 e8 r
#include <linux/kernel.h>
" r! J8 `; ~# C7 [#include <linux/types.h>! u' b5 f% q: B# H Z/ X( ^
#include <linux/gpio.h>1 N7 [5 E. V' w7 `. Z
#include <linux/leds.h>; y( b% ~! Z9 V0 e+ ?, f5 ?
#include <linux/platform_device.h>: S; _ ?$ l' _% W5 S
/ Z* u( D ]( @* D) b& J1 h: A2 P
#include <asm/mach-types.h>
; K) W* `- y! P#include <asm/mach/arch.h>" f% H+ m/ I5 z9 @+ U: Y
#include <mach/da8xx.h>/ J+ a( A' w' @- m9 p4 c
#include <mach/mux.h>
- a/ h0 ~- v. J! G8 G" F
" e( o+ v* O* W) n, W& t7 g0 T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' B U3 G& x4 K
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( Y1 |( k; X# R7 G1 s#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! i* c' t% D" p B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( F. V3 l9 p8 d( J; e8 D- j
0 N0 ]( Y% }% i& g# q0 P/* assign the tl som board LED-GPIOs*/
- l, z6 x7 ?' R6 l' e+ l& gstatic const short da850_evm_tl_user_led_pins[] = {
1 O* q" o* |" w- Z /* These pins are definition at <mach/mux.h> file */
' t# m4 ~8 A1 _- r) f: _: R DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! Q8 @3 ^9 i( V! @ ~ -12 v# k2 a8 P0 |4 p3 k
};/ H6 o! n1 A2 g: b: k' N9 Q0 h
* |6 k* k- Q" pstatic struct gpio_led da850_evm_tl_leds[] = {( J" |; u( G. N6 E
{
- y- r8 i# \! H3 i9 j .active_low = 0,& A3 q' |, G8 y, d$ y& G
.gpio = DA850_USER_LED0,
; g Y$ e! n8 p0 o* E8 m .name = "user_led0",: d. w5 D8 H$ R# m
.default_trigger = "default-on",
, t- m- O, n( G0 \; E8 B }," {) c' g! i, K) X
{8 J$ Q" J m3 c
.active_low = 0,
0 t7 a% S( U3 e/ |5 ? .gpio = DA850_USER_LED1,
+ M4 b2 y9 w; N9 }0 V3 B6 L) W# ? .name = "user_led1",
3 }! P8 G( Q+ F+ [' N, K, h .default_trigger = "default-on",
3 j, `' ^* k- f/ B+ E0 Y# Z- \4 G },
9 X) G! l3 m$ i0 R% l {/ ^) c5 v+ ?: y4 B2 }5 L8 P
.active_low = 0,! N$ b9 Y K6 \1 {0 M4 L
.gpio = DA850_USER_LED2,
+ `% B& Y1 c9 A' o& j, A* W: C. F .name = "user_led2",0 {9 b. k3 j% {: t1 V2 |4 m/ G0 Y8 ^
.default_trigger = "default-on",
( t9 P1 {3 r( i" A @ },
( Q# c( ^/ Y5 v6 X& w7 Q {: c8 q G, J! o) ]& r) G
.active_low = 0,
3 Y8 s4 u, }. t .gpio = DA850_USER_LED3,) X9 U% r" L# Z
.name = "user_led3",
/ O; q' H2 z/ \ | .default_trigger = "default-on",. O' q/ _+ z: b7 I
},6 }7 |' O1 ~/ H9 K+ Y7 m6 @. y
};
6 h: C# e. d& s. x1 M/ _3 S2 [5 D6 N% \7 E b1 E8 l1 @) k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 d5 U+ G9 ~" Y8 U) R$ b
.leds = da850_evm_tl_leds,6 q r6 T/ G2 ?/ B6 j9 r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ J) h0 m1 S6 O4 f9 h
};, o6 k, ?$ s5 q! ?" S% m' b! ]* k. i
8 u- _' K r1 S X
static void led_dev_release(struct device *dev)' I- A# t0 e( T/ O% y* l
{
! [- \3 J; ?% B};
$ V$ {0 _$ b3 h$ @- A$ s, W; S( y q1 g! V4 T p
static struct platform_device da850_evm_tl_leds_device = {( l# s6 ?" |! m' r2 e5 k1 d
.name = "leds-gpio",& j' X' o0 L' W& k9 P" _% X9 l
.id = 1,- ~' w$ C+ T% ]3 \8 ?9 A2 l# n/ F- i
.dev = {
- ?6 T! J7 V( H7 L8 [7 t .platform_data = &da850_evm_tl_leds_pdata,
/ o' E# ^4 R3 Y1 `0 d2 u3 ^2 k8 |7 ^ .release = led_dev_release,! G4 e% r; E1 B+ |3 y" ~& {
}
3 d3 ?* b% @" O; {6 ?. D; }+ A};' I& `7 j. k. c5 q# M! Q
" S& o: Z+ I3 f2 x# X. estatic int __init led_platform_init(void)+ ?' [/ @) K/ \4 t0 w
{& p$ J$ w4 h& y6 g6 X- N1 U9 ^
int ret;
. k. t% f g4 s6 \( V* k#if 0' z7 [) ?( k, o/ h! p! J
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 x; U$ o9 w; L+ J; V if (ret)
( ?- C7 \' F( R0 D pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% C& ^2 i" V; w6 x9 \2 _) X "%d\n", ret);
# I$ B( J& D9 }0 @6 {3 u#endif
) J0 F2 a0 I9 l; c- U ret = platform_device_register(&da850_evm_tl_leds_device);
# @: A- @/ P5 i) @- z! i' [ if (ret)
& x/ k" e' x7 }, h4 _1 ] pr_warning("Could not register som GPIO expander LEDS");
* q4 s. G+ Y. [; e: b; M4 b else
# ]) V% Y7 G/ G* P) [ printk(KERN_INFO "LED register sucessful!\n");& c, w3 N3 ?; T, k2 @5 T
/ ~& \* w6 x3 W: I
return ret;: g" l) L& A: F5 Z6 |
}- ]9 y( N: H/ ^1 k8 z
& e- o% i' O4 O5 P* Ostatic void __exit led_platform_exit(void)
$ K9 ?: D4 ?6 p* N8 r6 Q5 g. I{
% Q. c z! P) w platform_device_unregister(&da850_evm_tl_leds_device);! S7 b9 s& a" Z
, b1 n- k& I, I; f printk(KERN_INFO "LED unregister!\n");$ l6 M- u1 Y9 W7 m( v8 T
}
% |; _$ k0 U1 N: v, r# W6 {- ^7 H2 h. b) s
module_init(led_platform_init);9 M7 T! L W7 ]
module_exit(led_platform_exit);
/ y0 z0 V0 o, N$ \! q5 S2 q1 l
* \ m( c& o# V- o) FMODULE_DESCRIPTION("Led platform driver");% h9 o: U' F3 C" b) y( q# j
MODULE_AUTHOR("Tronlong");7 F s# [1 D/ p3 H$ O$ t; _
MODULE_LICENSE("GPL");. Q6 @& M4 ^) Y' F9 y
; @, i$ L; X" T5 P8 \
|
|