|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 ^) X9 }0 X, s& L* H! N* Y
#include <linux/init.h>6 j- Q4 Q# q, h& ?
#include <linux/module.h>1 W% ]( q" E$ _. {8 k( h
#include <linux/kernel.h>
8 B6 T5 M) b( ~8 ^* W2 G4 Y% x, `6 t#include <linux/types.h>
h+ k& `' D3 a6 u, I#include <linux/gpio.h>
1 z- U" {) L. i' b; \4 a#include <linux/leds.h>
% e: |, M q' Y#include <linux/platform_device.h>& K. u0 s1 j8 x
; h! _1 Z7 k6 }3 K/ w. F# w
#include <asm/mach-types.h>
% Q% D' f$ X* @* s! u6 x#include <asm/mach/arch.h>
& V$ j7 p! b2 O9 L: g" |0 ?2 a#include <mach/da8xx.h>6 `; ?" V, y! _8 v* h& k/ T
#include <mach/mux.h>
) q0 a# U' V5 M7 l* k
* k( F+ b- j& Q% W; Y# O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): Z4 }' t6 {- H( m% n5 S! B$ P
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: h8 z7 ^7 e# v. m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- T% o+ b: {6 @& B. |$ X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): X' r4 P" A/ s3 w9 r" {
5 F; |1 a, H8 Y' d: w/* assign the tl som board LED-GPIOs*/& {% z U) a2 x( k1 P$ S# S8 p
static const short da850_evm_tl_user_led_pins[] = {
5 B3 j0 j' \ e/ ^0 L /* These pins are definition at <mach/mux.h> file */3 E/ F- @5 V( S& ]* R' W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ p) S# v/ Y `' E5 ^4 A) ~5 d -1
; ~' d$ g2 n/ k6 D) |};2 E- j0 C( q: ~2 r1 r
" R. o% i4 u1 H& U
static struct gpio_led da850_evm_tl_leds[] = {0 v# i! z2 P( i1 g: J
{3 ?0 v( ]4 ~8 D
.active_low = 0,
9 d- D& R H A- [% t .gpio = DA850_USER_LED0,
C' A* @* G/ n .name = "user_led0",
( z7 b+ |9 ~0 ^- |. l5 E .default_trigger = "default-on",1 \7 r$ A3 D: L, A) S% {
},
! P- b1 A9 f' v6 C: h7 m# Z {
" Z7 U& y1 B; \) I8 R/ m .active_low = 0,
% B( {6 g p" @; Q3 g% B .gpio = DA850_USER_LED1,
# {, v( [8 Z% z6 K1 x, n) H% k" n .name = "user_led1",9 ]5 y. w1 K- s' ^
.default_trigger = "default-on",
3 d, f9 X; i" r) V },
- g' M0 T6 ~+ m. W- S9 ` {( _5 _( H3 E8 b; |3 K8 n' T
.active_low = 0,; s# b% N4 a! [* b
.gpio = DA850_USER_LED2,$ X; w' a: x; w' q
.name = "user_led2",5 m; W& Q* k+ e; c; [+ G
.default_trigger = "default-on",
' c4 j; O& W9 U4 S9 H: | },; c; g* X4 r. i1 M% k/ q
{: V6 u! G* U4 ^7 ~/ { c0 s
.active_low = 0,5 _" o1 S1 u+ _. v: [( J. `
.gpio = DA850_USER_LED3,
' S- k' P! m# b# p .name = "user_led3",
4 _3 T1 }$ ~0 u, V2 Q .default_trigger = "default-on",
3 j3 N/ X! _2 M },
! u4 z- G" w! e( D! Q q# O4 {};4 X6 F1 N! ^# m* I) J1 x
2 v$ ~* Q+ q3 e( J Q5 Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 B- A$ D0 t' d" x2 E5 j
.leds = da850_evm_tl_leds,5 @$ G( }$ y0 @0 V+ a3 i
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 f) d! i/ q% o( a: D! E
};
5 [7 H! Z; `2 G) w
6 w6 q3 \2 k' Pstatic void led_dev_release(struct device *dev)
$ |2 G _5 V" Q# h3 \0 r{
9 u3 i/ s$ A6 U( `9 m: ~};
1 I7 y9 _1 w3 a Z! B' T* w# { x0 T9 X6 K+ ~$ F
static struct platform_device da850_evm_tl_leds_device = {! W* ~9 H% W: z8 a$ H
.name = "leds-gpio",
& i" v+ B+ x% A; ~ _ .id = 1,
: X) K% W8 h$ f/ v, V4 \; | .dev = { k5 I C2 x: x& E2 j: c
.platform_data = &da850_evm_tl_leds_pdata,1 P h0 j' b R; P8 W2 _; h
.release = led_dev_release,
7 d, K1 _ f) G" g# _+ y% i; T: c } P8 r9 o" U4 ~: S2 l$ \
};
. S; w5 p- d5 J: F: r( h
& K2 x2 o& W: Ystatic int __init led_platform_init(void): d" b, N9 `" O( O; Q: `7 P" C# [4 G
{
% n' x5 F3 q8 W4 X+ J int ret;5 z( h; E9 F' |0 u/ S
#if 0# [$ {. I. q# W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 {3 l4 N5 ?0 S5 U0 w
if (ret). U; h7 B# e" p4 n% r8 g" t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 U! w" b U4 x. _" a "%d\n", ret);- K# p* [6 I1 k6 a2 q2 v
#endif ]* ?6 n; A( J: |
ret = platform_device_register(&da850_evm_tl_leds_device);
+ u& G5 ^/ \* Y2 k; _. @ if (ret)
0 K0 X! j f! Q/ w pr_warning("Could not register som GPIO expander LEDS");
1 V4 D- U+ P7 T" S2 V8 F- C else
& r2 Y* N1 D2 J( C( h. D' r printk(KERN_INFO "LED register sucessful!\n");( Q2 q& B9 n) h; f8 |* Y# v; O. i; _/ M
& Y# Y2 G, P0 K q$ S
return ret;
2 y V1 d$ n$ H5 e" o; v}
; F) Y2 a( O2 ~( X( m4 C
4 n2 ~- [' Z& Q" E, J( s1 {static void __exit led_platform_exit(void) U9 c c* w. L& y, O1 ?
{2 ~2 x9 e+ ~8 ~8 E( E! d; \& ]% ]% {
platform_device_unregister(&da850_evm_tl_leds_device);8 B$ D8 b+ j$ p9 x4 }, _! G( Y
& B& f4 h' [( U- v& F, g
printk(KERN_INFO "LED unregister!\n");
! X' W- v; ~" I6 j}# N+ J& F6 r5 F L
1 g8 R3 Y$ ~- _ |0 A* W, Bmodule_init(led_platform_init);: l8 j" F& R9 R5 Y
module_exit(led_platform_exit);
0 i3 W$ t9 |7 _+ e+ V2 ~$ n6 [$ x$ x5 z" g3 U) S6 d
MODULE_DESCRIPTION("Led platform driver");
4 _" f9 ]: H4 ?& IMODULE_AUTHOR("Tronlong");; w) l Q, g- o s
MODULE_LICENSE("GPL");
9 g8 B0 ~6 L0 ~2 O- s' c& o4 @
" Z$ u; B8 x4 U! L, x, X6 x |
|