|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! C2 \; G: b: G0 R; C0 e
#include <linux/init.h>: A4 P% h6 x# r
#include <linux/module.h>
* S+ F) y$ C$ [3 w#include <linux/kernel.h>
: r1 R# x/ P F' C. q#include <linux/types.h>
5 D( V' U P" u0 G- W& _#include <linux/gpio.h>, t3 y) {% x8 w6 n& J
#include <linux/leds.h>
! u4 }5 T. x% f5 k% R& {+ f#include <linux/platform_device.h>* d4 m5 k0 N- ?7 `- @3 z
4 J( [* `3 o" _1 U( Y1 j
#include <asm/mach-types.h>
' L, _) K( o- P, C" U( R' u) \, R#include <asm/mach/arch.h>& D* x( N8 Z. x& f
#include <mach/da8xx.h>3 O9 @0 k( l' u: X. z) l1 g
#include <mach/mux.h>* ^$ T0 s5 V4 X( Q9 {
4 t% @2 j) M# a3 ]6 p: S, W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 j+ [( m H' e3 d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# P6 @% K# V5 S+ }4 g+ J- Y7 {, F#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ A, {( [: L, W#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) k/ m7 T2 v" \' [4 j1 i) _) H
" f7 b/ u: ]% M( g+ H, }- | w+ F/* assign the tl som board LED-GPIOs*/* _! @, f9 a% N; F5 M* m
static const short da850_evm_tl_user_led_pins[] = {! h, s3 @9 _; u" @4 P' H
/* These pins are definition at <mach/mux.h> file */
" S$ R" ^& l4 h" T% D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, ], t8 b: h% N# w: h -1/ s5 @7 C6 w+ k1 u5 g+ n" |3 F+ g
};4 ]& w% q& S+ V# B1 p. s3 v
' p9 \+ A! g) }static struct gpio_led da850_evm_tl_leds[] = {+ ~4 n) `4 @9 m; e1 s, @( y
{
" t) y* Y e5 } .active_low = 0,0 d: w1 n8 o: v5 o: g5 u
.gpio = DA850_USER_LED0,
/ r0 D% q! J) M$ R% e& K4 m3 F .name = "user_led0",
3 r3 ~, B! G$ U( O e .default_trigger = "default-on",
" S- X [ G: G" w! Q },
" B3 M2 |$ E+ P; ^* _0 X# [ {
; ?' L: V9 K' b .active_low = 0,
, O3 _0 \* A/ \* n# p; N8 [; W7 L .gpio = DA850_USER_LED1,7 M: y& D# [- O" D3 S) C( ]1 b: e
.name = "user_led1",2 _2 u+ A3 _9 T# G c6 D2 r! M. N" Z
.default_trigger = "default-on",
" S% u& @7 X0 z5 a/ b },7 U3 m$ R, r( I1 w1 [/ w, r
{* K1 U$ {' X$ o
.active_low = 0,, [, t: Y1 A: c. _; m9 E6 L
.gpio = DA850_USER_LED2,: J5 [" e9 a2 b/ k+ J' E
.name = "user_led2",
9 V# R' Z. r+ G) |! ^" G .default_trigger = "default-on",
/ P1 s5 B+ l6 T4 v2 z, n/ l },
$ \. W4 o& Z2 Z2 D! M {3 d1 }& d' J+ \% U/ I* g# O3 |
.active_low = 0,) P# T9 ]" V4 e" N' c T+ s
.gpio = DA850_USER_LED3,
. H( x) N" V5 @/ n2 u( o .name = "user_led3",9 M P* T5 H1 N2 |/ L1 z. ^
.default_trigger = "default-on", \# w5 \4 v" i7 X0 Z* x1 i2 J
},
4 N% D4 p1 M7 r' c4 w9 Q4 l( i3 }};, _' u3 b7 d. j5 u1 v
3 G* g2 j O/ b& T. Q- t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* B$ Q" G0 s- b
.leds = da850_evm_tl_leds,
; b& Y9 A" N6 i. l8 A( w9 o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! i4 m1 |7 @' D ~8 i3 V
};* ~4 \$ E9 V( z5 V- A
# `" }; C+ @& a# rstatic void led_dev_release(struct device *dev)4 C5 \7 ?9 ^0 Z' h, v7 \( |
{
2 U0 V; Y* m. {* ?9 b G$ j$ _% s};- }# o7 l6 y$ D" K; G x
7 v; D8 b; F F% D3 Wstatic struct platform_device da850_evm_tl_leds_device = {% \, X8 {4 p2 I& m: q- ]4 [; L6 L: i
.name = "leds-gpio",6 [3 E' v" M2 ^$ @3 E: C8 e& N
.id = 1,
7 ], R, }0 ?3 w S4 g .dev = {
" w6 R! m8 V, A# `. N .platform_data = &da850_evm_tl_leds_pdata,7 R* A; l W& n* d, a* q9 Y
.release = led_dev_release,5 o) b9 A2 G9 v# a
}
! i& W. F3 K; G6 j0 H9 l; U};
) L$ R9 r3 k6 d
( l# [0 N( E/ r% L+ P: Ustatic int __init led_platform_init(void): m3 `: y/ q( O% v; m. \! U$ J7 d
{
* P% Q5 E8 E0 S( X; N- F e3 S int ret;0 f' C4 j! \# L3 w8 H
#if 0) h8 [4 _9 Z3 s2 M9 j; p
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 L7 [) R' z6 l) X6 L) K% T if (ret)
$ ^' {! n$ n. D" c. E8 p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" e! u& }/ y2 I! d7 @$ Z! k* Q "%d\n", ret);
! K, F. E0 m. {: P m#endif: _8 ^2 a o; a3 `
ret = platform_device_register(&da850_evm_tl_leds_device);
8 c% z# s- g3 s: h, {: r f$ m if (ret)
0 x7 d Q7 o' |% H* n6 T. o pr_warning("Could not register som GPIO expander LEDS");
3 u, w( X( |! d8 D else
7 Q; \$ S7 m# `5 F' H4 t2 T! N printk(KERN_INFO "LED register sucessful!\n");1 r6 f t! g, r, E) c
! H9 W) J! N5 d" ^3 N" J
return ret;" i; _3 u) _: }
}
, f# ~0 L) P) {$ A
/ c7 `5 R3 E7 d5 c5 O/ jstatic void __exit led_platform_exit(void)
8 D7 [2 t. P/ I, s1 A1 v$ _+ l{
/ P9 u" I5 U% X( o platform_device_unregister(&da850_evm_tl_leds_device);4 {: U2 F: ?& |" p4 [% @& t
5 ]+ F# m7 w# T% Q* h% H& {, e- Q' h% y printk(KERN_INFO "LED unregister!\n");) V: F/ q& q- J) I0 b7 k1 a
}: m! m$ u8 f! \ K5 ^
- C5 l( V4 f+ o& b! E _* Q- M$ V% u% x
module_init(led_platform_init);2 |. c$ J% m; M- K
module_exit(led_platform_exit);
# x0 A- E% ~/ K( I' d- [9 }0 G: p: n# [# D7 L4 ^) Z9 t3 k3 U- @' b
MODULE_DESCRIPTION("Led platform driver");! @7 {' ]# a4 w- S1 P/ P$ T1 S
MODULE_AUTHOR("Tronlong");5 {2 H9 n$ i5 b; d3 F
MODULE_LICENSE("GPL");! H- U4 Q I( T; r8 P( Z
! v! `# k0 y p" C
|
|