|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ ]6 Q7 M9 T+ c9 |
#include <linux/init.h>+ p8 G7 f' n/ e8 H% R
#include <linux/module.h>7 i& o& G5 M" F/ B, q3 v- ~% B6 Z2 c
#include <linux/kernel.h>2 P5 _* ]8 p4 W% ?7 X/ l
#include <linux/types.h>5 }; e+ H, ?% g, D2 Q4 Y
#include <linux/gpio.h>
7 v! G( O" M" ^* \/ Z1 M* k#include <linux/leds.h>* f3 {- }3 }. H7 i
#include <linux/platform_device.h>5 {3 D2 ?0 A3 J) F0 ^
( R& \$ @0 I8 n- x#include <asm/mach-types.h>
; _/ j- e0 d0 m3 O- W6 I, \: T( x#include <asm/mach/arch.h>9 ^9 z% A8 x, t0 a- }& y- y
#include <mach/da8xx.h>$ P& Y8 i) {: A% V# P7 H8 k
#include <mach/mux.h>
/ B3 r. J' { J0 f
& N$ \, a3 P9 f/ S' n2 Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 l. j, \3 V% T, b) S: `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* s* ^; j2 G0 r! A6 I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ _- W; B5 H5 p4 v" q: S8 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 r7 I5 C* ?% b1 v. N
& s, c- S8 Q: Z* F+ ~$ I, G/* assign the tl som board LED-GPIOs*/) z" r5 r$ N1 M6 w# C3 v
static const short da850_evm_tl_user_led_pins[] = {, l+ |; R3 Q7 H! @
/* These pins are definition at <mach/mux.h> file */6 k: O2 Z: U% d l
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' W6 [, f: [$ b# u; f, k -17 ?& ~0 E% {$ ~* K- l4 q- `
};& ?: W9 p. \4 O3 B8 g8 C
0 F# u/ j# z4 G/ i( [2 t" G
static struct gpio_led da850_evm_tl_leds[] = {5 [! H% S" O5 H8 k3 }" d: x
{; N* b, N% T3 x: _! |3 x4 f
.active_low = 0,
. `! H3 P! P1 `4 e .gpio = DA850_USER_LED0,
: M6 I' y n& ] .name = "user_led0",- e2 _" T- @6 L" L& Y1 W
.default_trigger = "default-on",: K! n# g( R+ A" o5 F
},+ ?) u( m, K. E' S4 L
{
* t5 S; f/ J- I% u) ] .active_low = 0,1 O! @5 N' k6 [) [' M/ z
.gpio = DA850_USER_LED1,
! z/ |3 s) C- k1 k .name = "user_led1",
( c J" O! I k+ k# S( e4 y .default_trigger = "default-on",
. L5 I- D; p1 L0 N& c+ x( { },
6 T5 O- u' u4 Z, X9 U0 ? {( k" F V* \& M+ ]. F
.active_low = 0,/ e! E- U [- W, b6 r# B
.gpio = DA850_USER_LED2,
/ E3 u4 A8 c! A .name = "user_led2",- e( M5 S2 C- L. L( ]
.default_trigger = "default-on",$ A+ m- }8 b3 ?6 D$ G3 {) g$ N" s6 t9 ]7 ~
},. }( e: q8 c* c# f
{' F3 \ I) C% `* M; L6 g
.active_low = 0,) t; l: W6 j/ d, K, U/ S; J
.gpio = DA850_USER_LED3,
" D' i7 ]+ l$ [) ~: m! ~* e .name = "user_led3",
6 u1 [* t1 }, [- L .default_trigger = "default-on",
: q! n. Y9 _% i$ V) W# o },* ~: y' r- S( ]! s2 P2 \6 l3 j
};4 B# }$ H. g2 S; l2 A- m3 c1 t
$ e2 l l/ _5 |0 }; v4 L1 Tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 v: A. d k7 H
.leds = da850_evm_tl_leds,
1 J; |% Z+ n O0 [ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# a6 M; \% i6 m( q1 G};
4 j9 p1 _* r9 f0 {$ k7 A5 z" P* h8 j# A* O
static void led_dev_release(struct device *dev)6 p0 P9 W+ P* v
{
3 a7 u5 a; _; d2 W};
k& h: L- E4 a" y' R
0 U6 w; X- x5 Z; O6 A( Tstatic struct platform_device da850_evm_tl_leds_device = {
, I& e" ~+ J' ?! x$ s .name = "leds-gpio",
( c2 j* P; d5 f. y L1 e .id = 1,6 f+ ^, C {9 a& l, c
.dev = {
0 o, B% g" q) M0 M$ d1 t4 r3 q .platform_data = &da850_evm_tl_leds_pdata,
& m$ x6 y# L% p* J3 ~& T1 q .release = led_dev_release,& {. l5 [ \; @+ ^9 V
}
, j8 F3 a9 A+ c' `+ I) S. ^) @};
$ V0 H3 ]; p Q# l8 {( I0 U
; F5 z M: k; Y* d: ?# Qstatic int __init led_platform_init(void)( V$ m3 l( u0 k0 x. x) o$ w
{( m' J% S# e& c
int ret;' E. J. L0 e; L+ f! a
#if 0
; B, n# g2 K6 G, v0 g( p ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* Y1 s2 m, ]% Q: z3 X# [' j
if (ret)
2 J0 P3 P" j9 j: @1 l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ ^0 s7 z0 {2 \) D+ F/ ]6 W7 P
"%d\n", ret);5 O, ?5 G: p( a
#endif7 z7 l1 ], M; d! s' p& U4 t0 O
ret = platform_device_register(&da850_evm_tl_leds_device);7 B/ a/ B$ l8 H7 `' M& P- O2 e/ p
if (ret)
) _$ t' Z$ Z( a pr_warning("Could not register som GPIO expander LEDS");
# k+ z) [4 r: i$ P, R* T& O0 S else
% D& s- v! s5 e$ A& p/ Y printk(KERN_INFO "LED register sucessful!\n");7 H5 X* I9 P7 a5 o. u* H
* K9 y+ C$ a3 c+ `5 h4 L2 o* c2 a2 H
return ret;) I0 t3 e) l( u+ S' }& B3 z
}
7 Q' r0 n1 |: q& v/ @, {# b# m
4 S% z' C5 M+ O: I$ }0 I6 m- [9 dstatic void __exit led_platform_exit(void)3 A% @6 `! ^% L2 E1 d( C
{6 j6 T% K3 t; x! R( \) e
platform_device_unregister(&da850_evm_tl_leds_device);5 h$ ]6 u5 ]: _7 g; x: f$ f9 ^
9 g- N3 f/ u5 r5 w
printk(KERN_INFO "LED unregister!\n");
& [9 {# m* x4 S. L, l+ k}
}; u( x' ~; D7 Q* q! r6 c
: u7 T. h* F5 N7 umodule_init(led_platform_init);1 z2 c5 x9 b8 ?
module_exit(led_platform_exit);* }8 K& k' R! o( r0 k
2 `, x6 D% x3 E+ {
MODULE_DESCRIPTION("Led platform driver");
! P% v) f3 c& j- fMODULE_AUTHOR("Tronlong");
) J& ?7 F8 m; B: XMODULE_LICENSE("GPL");
$ b* b4 X* }# [; g) B* t* V6 W$ k4 l2 r: ?$ i: F" d( ]" F9 x
|
|