|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 z7 S3 V6 r1 |: [. x( q
#include <linux/init.h>2 f8 A1 G! o; q |; x' V8 C) ^5 W
#include <linux/module.h>
' u- b' c" Q2 w4 ]* _#include <linux/kernel.h>7 h% K& z" [1 ^7 w2 O
#include <linux/types.h>
1 n3 Y- B6 W: n" J6 ^9 u u- ~) `#include <linux/gpio.h>
, s' A8 Y/ g$ s4 h0 E#include <linux/leds.h>
4 A# F) g% E- R4 J3 R2 P#include <linux/platform_device.h>. Y$ b3 H# x @" H t
, ^+ o8 H5 ]! i' j3 P
#include <asm/mach-types.h>% { Q9 \$ [3 ]
#include <asm/mach/arch.h>
) i% m* U0 t+ C# ]#include <mach/da8xx.h>- F# n2 J9 {0 @7 ?* R; p/ K" X
#include <mach/mux.h>
- O) F' d4 L9 x
7 i& }/ \, r/ Y% p. c6 f#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 W; X) U) \/ k! V#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 p& R+ {# M- `/ D( L#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& q8 N, s. O4 n, w- X' ]' A#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ f: o5 M6 F ]2 Q& h8 h
U- Z& I8 i9 I% N( o
/* assign the tl som board LED-GPIOs*/
1 F c7 Z9 o4 x1 L+ w2 @: m* `static const short da850_evm_tl_user_led_pins[] = {: F) x1 ^! K Y( d' v4 V- a
/* These pins are definition at <mach/mux.h> file */
8 X+ w: N$ S$ v, D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( K& a# E! i& }' ]9 m
-1
3 ]* v, z0 E8 v8 r};( G" O* |( \1 b$ a. a. M
2 }/ C: S! p$ x
static struct gpio_led da850_evm_tl_leds[] = {$ A# @1 O z$ {! \# v- S) z6 h2 h
{
1 P9 m7 b J0 V9 u( M1 f7 F$ V .active_low = 0,
* ^1 I6 v* i* U9 G9 \7 o% J .gpio = DA850_USER_LED0,5 _) Y% q. ` D; s7 e) q. q1 s- N
.name = "user_led0",
4 z1 r2 v6 j+ L. z# h+ u" Y .default_trigger = "default-on",( [) Z) J. z5 u5 H* T; p( p
}," k* @) n- g/ c/ f$ a
{2 U; c- ]; b. W+ l
.active_low = 0,6 b( }# {2 j! z# x8 J( f
.gpio = DA850_USER_LED1,
! Z9 H$ L4 F# \6 i1 l6 S! Z7 m6 { .name = "user_led1",
( |8 r5 m! _4 o* r0 | .default_trigger = "default-on",3 k( W! M1 `- i/ R3 U
},$ y+ ? P/ @$ T& b
{
6 R2 c1 w5 w d( ~5 T, m .active_low = 0,! _! N8 y6 ~2 U) J# s7 }; N7 m
.gpio = DA850_USER_LED2,
9 e& {5 u* j9 S- Q4 q .name = "user_led2",
3 H' r; {2 |- S1 @; ^% { .default_trigger = "default-on",+ T1 S0 j0 D' t: N% a+ d) L( C) o P
},9 l/ [% g$ ^# J* f) v6 d
{
1 Y& o$ \/ i \6 F @! w, S) _' } .active_low = 0,8 Y9 s/ W, t& U3 Z+ l9 H7 h
.gpio = DA850_USER_LED3,
2 @$ y; L( X! T1 @ .name = "user_led3",% c0 z* y) N3 m) n3 A9 d8 d
.default_trigger = "default-on",
2 i; O5 c/ @' j+ [9 N+ d+ A- l: k },
7 ~: Z6 Q3 Q9 @% k+ Z};; `1 S2 E% L) u6 W3 u
, b5 w0 G7 N7 Y+ ~- {- astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 H: \" |9 b; [" J& y0 y1 p
.leds = da850_evm_tl_leds,
" Y$ v8 C6 G; a | .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* h% Y3 P9 d5 E
};* D$ }7 G" h( A+ P
2 V6 U$ g6 J" V9 P- t7 Lstatic void led_dev_release(struct device *dev)
) v2 S# c3 O1 L3 [9 c' r0 ^{
3 |: O1 u2 y" {' d' n# [ {' d& l};( q3 q$ M8 P/ }! }' d0 m
. H* e. y, h- K4 H6 T7 B5 `static struct platform_device da850_evm_tl_leds_device = {
2 Q Z* @+ ]: q .name = "leds-gpio",' Y# E6 a8 V a" ?' K
.id = 1,$ z* U" M0 o) v8 Z
.dev = {+ J1 S' Q5 s2 |. c
.platform_data = &da850_evm_tl_leds_pdata,
/ f: |" v! l4 S# i% o( O/ v .release = led_dev_release,
2 w6 ^2 j" w5 m8 M2 V) f }* {2 x, k7 r" G8 E; H9 N
};
3 l, c2 J+ Y) K$ {; p, H: D8 V1 L9 ^# `% q& u
static int __init led_platform_init(void)
4 {% x* x8 y" y' E8 ?{# ~0 t& ~1 V: Z( W( k
int ret;
8 }2 Q2 C3 g/ ~8 ~8 x#if 06 w3 G7 L% s* q" ]# c7 {% \2 K1 G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 V2 U2 x$ A, F& x7 l: B+ \; ~- F if (ret)
5 P7 _2 \1 c, P/ u8 ?! X' c pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 A6 g, ^' ~ l8 W+ Y8 l* E) ?
"%d\n", ret);
) |5 l' {3 S7 J4 X) n8 ~7 k5 ]#endif
0 U. E1 w; R2 J* P( o# |. e5 D$ A8 F ret = platform_device_register(&da850_evm_tl_leds_device);( I8 D- l* I( E8 N7 D7 {' N
if (ret)/ O3 p/ _- P# m# i; I
pr_warning("Could not register som GPIO expander LEDS");, h" J. t7 y- |- y$ @
else
) y% s) e1 A- q- N! r printk(KERN_INFO "LED register sucessful!\n");
& W, {/ L4 s; x
: N) o& w; y; ^* F return ret;
8 _' j6 ?9 e X: w1 m. B}
, ~) V, N. [! E6 K. |
' G2 N7 q6 Y# Z- _: n4 kstatic void __exit led_platform_exit(void)5 Y# W' q3 @+ g7 N! f
{4 t6 Z+ W8 \) {% l" z3 } }; R
platform_device_unregister(&da850_evm_tl_leds_device);- C f$ C1 J* r6 X
, b( M1 ` m- M6 E
printk(KERN_INFO "LED unregister!\n");5 a# u) T9 t' _; t5 i& G/ B) l
}
# c% ]; ]0 |7 X. P
! S( ~+ j0 i6 A; Pmodule_init(led_platform_init);; I( [4 L: l- O' }: k0 R; v
module_exit(led_platform_exit);
% t2 S, L: L# x6 ]. g s& m# V. @; L" ], e; C
MODULE_DESCRIPTION("Led platform driver");1 c9 f" D# n, p. c' r
MODULE_AUTHOR("Tronlong");
1 I' P' y: x* HMODULE_LICENSE("GPL");
2 `+ D3 [3 |9 @5 E$ J! h
5 ~- B3 e5 U5 O) |( p6 v( E |
|