|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 x4 F3 e' g' y* Z6 Q% N
#include <linux/init.h>6 K4 m1 a0 z* o- v
#include <linux/module.h>7 G6 }: |, ~- N$ ?+ q$ n
#include <linux/kernel.h>; H- T0 u/ x$ _' L% j
#include <linux/types.h>* r7 p0 R5 p- I7 i( [* [/ X2 A* L
#include <linux/gpio.h>& H% {8 V v2 w3 h% L
#include <linux/leds.h>
: w% _6 N( c& g! ~#include <linux/platform_device.h>4 D/ R$ D3 J6 p# Y2 m" {
* ?% _* T( I( P; ^( y% \
#include <asm/mach-types.h>* R& P r9 C1 y9 E$ B! x1 V9 Y
#include <asm/mach/arch.h>$ {* q$ L7 l: ?
#include <mach/da8xx.h>
8 j9 P' k& u: ^8 z/ s0 S# a! I#include <mach/mux.h>" Q3 {, ^! H2 j3 Y+ N( L* V! F: R/ s7 g* i
. K- `3 M5 j. z( A, {* M$ I! P w
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, n( c) ^6 y5 x- k# t#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& K: Y% e* e5 A: W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, x/ }- y2 C E/ s9 S; Z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) e$ P8 [5 t$ e9 S2 b* w
( [ ~4 N, A- L% ]& f% e- o @ ^/* assign the tl som board LED-GPIOs*/4 o3 e$ S0 K+ n2 Z8 S* J
static const short da850_evm_tl_user_led_pins[] = {6 p, n4 f& B5 o+ R9 \- M
/* These pins are definition at <mach/mux.h> file */
9 y9 a3 _& V- J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 A$ B( f- }$ @+ [; A* M' C7 g
-1
& q! ~6 q! }+ Y. T) B};
' p; t% z! x F6 E2 ?2 z# o9 c2 M- @( N1 U! ^* }1 D6 g
static struct gpio_led da850_evm_tl_leds[] = {3 }$ a; M! M4 P( U
{
+ f$ `; w2 N3 D+ p1 L" K2 @. M .active_low = 0,2 k4 l/ X( `" y* G Y9 S1 X* H0 y2 ?
.gpio = DA850_USER_LED0,
! W$ G" L5 y# G .name = "user_led0",3 G1 l C- w0 `0 \. n1 N0 F
.default_trigger = "default-on",
: ~- A. C" K& d% ?% q },- e' y% I& p+ j' ]
{8 Z% [. k* P* ?2 }. j, m( p. S
.active_low = 0,
7 s+ J' [! X1 G! H6 q0 V) A .gpio = DA850_USER_LED1,
$ }% d$ c+ K6 {6 I .name = "user_led1",
' f5 {: y# h7 H' s1 o) F .default_trigger = "default-on",
5 o9 \( }% x0 `7 u5 p% ^# m2 S" v },* D& B- m' `( l" \8 m, g7 Y9 C
{2 l R& k; `" y! p+ C
.active_low = 0,( ~4 H# q3 {) R! L2 G
.gpio = DA850_USER_LED2,* U/ Q& s" [& R; u+ u
.name = "user_led2",
9 r: w2 E3 e" P .default_trigger = "default-on", b9 d8 Z9 V0 I
},& g" w( H& h6 E( @! t
{
* C3 D- `8 w6 V: I b .active_low = 0,
1 R/ x6 I. E# r" u5 O& V' D: G .gpio = DA850_USER_LED3,
: k% {/ }& b/ y R$ Y% [: r .name = "user_led3",# l& Q: x' W/ _
.default_trigger = "default-on",
( N. f! f: ?# R* M1 v/ A },: U: `. x- b3 z6 k b7 R7 k
};
1 P" K3 Q( p& l8 Y( D
, r% K. G* X: L2 Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# k9 |- C& V6 m u: u {; _+ b .leds = da850_evm_tl_leds,
( k/ u/ N4 l5 ]' _, u, k# f .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 Z3 v% \! S5 ?1 B# t9 p% P" T2 ]( K# e
};& z7 H+ Y& p6 R) Z+ E. D
) }2 \7 Y, f+ |' q0 n5 H3 ^0 Estatic void led_dev_release(struct device *dev), P t: J6 K! Y2 j
{8 @1 R6 k0 c5 D; x6 H
};
1 O) r( y* D, R& ?8 C7 {3 m! o7 s: Z& P. P, i" ?
static struct platform_device da850_evm_tl_leds_device = {3 f1 L3 V1 u2 l0 [
.name = "leds-gpio",
+ t- y8 f% n6 L8 d+ m7 a1 v .id = 1,. V; G' }' D9 s8 G
.dev = {1 x- p/ r1 E7 q! d- O! m! w
.platform_data = &da850_evm_tl_leds_pdata,
3 K9 T7 v" a" q. A( j .release = led_dev_release,, N! m' z' q2 J4 T) K& v" [) a2 b
}
2 H! k0 k0 `7 d W4 ?8 N};8 P3 z. G( t5 n" s0 m
, N9 A C3 F( X7 k# D* fstatic int __init led_platform_init(void)
2 L6 n0 p0 E5 ~& ~{
" g' r$ }) {. y, v' V int ret;( m! ^6 j5 W; H* k; E; f4 A9 _) |; U3 r
#if 09 X( V9 |2 D) T0 w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" V' A% n; {7 A! [ if (ret)+ [9 P6 o( u0 o/ m+ l# s, [, o( k
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- x' t* y9 i1 ? a) I
"%d\n", ret);4 \" v; J$ c1 s
#endif
) }7 n# l) a: Z1 c% P ret = platform_device_register(&da850_evm_tl_leds_device);
" ~$ `( b) Z' m. b* E7 Q3 \- ^ if (ret); T$ Y2 E; l1 ^& q7 c
pr_warning("Could not register som GPIO expander LEDS");
4 q2 j* C0 t8 t else& W2 ` z6 |- d+ N" G( R
printk(KERN_INFO "LED register sucessful!\n");: F" S4 `/ K4 J+ {" |
" P4 h1 S( S8 I: d/ o! M2 M return ret;
! R/ |, L! ^. Q}( Z- J0 v' I, ?( L I2 K
9 d4 g2 a1 |. I% P# U8 t; U' Y
static void __exit led_platform_exit(void)+ r3 v7 \- B" m* s& I
{- H) g2 H- w4 H! _
platform_device_unregister(&da850_evm_tl_leds_device);0 Z+ X" O6 }; a/ v9 ]
! u, ]! U% r6 H. C0 s0 _
printk(KERN_INFO "LED unregister!\n");
0 S) K! \/ T, B; T6 _" u}3 e4 h1 |% F+ |
9 `5 L) G) e4 @. m: p
module_init(led_platform_init);
! \/ g. [9 s' w) B! w) Q* [module_exit(led_platform_exit);
! h# |( B# [- N& a, ^4 M) W3 A
) {( |% i3 t; i; D+ SMODULE_DESCRIPTION("Led platform driver");+ Q# ]* @* K" n+ k+ u& {
MODULE_AUTHOR("Tronlong");& u3 z! t ]5 I1 c" U/ a
MODULE_LICENSE("GPL");
! l6 J3 w7 e4 ]
. f+ \' L( z4 N% }6 y) e: p; L! n3 R |
|