|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: V3 T( m' H, ^% m4 z. E4 i9 ^#include <linux/init.h>% P/ U. R2 C" ^5 H
#include <linux/module.h>% t+ H0 R( m9 L7 u# k+ l
#include <linux/kernel.h> c' N6 r& W: X. m1 R( v% e' {# v
#include <linux/types.h>, S r0 j0 R- R3 Q* f J
#include <linux/gpio.h>1 Y, q" |, Z0 g, s2 R) t
#include <linux/leds.h>$ B# o7 t* S% t+ M3 Q
#include <linux/platform_device.h>
/ d1 J6 e- \8 f0 S) T" G$ k
0 R+ U: e0 ~# z& D6 M7 V" @6 W/ ?* b#include <asm/mach-types.h>, L! X0 v' u5 X* G/ e/ w% L7 l" o
#include <asm/mach/arch.h>
0 C3 s# `+ n; r9 l2 n#include <mach/da8xx.h>
7 n2 o/ A6 F# s5 u3 p#include <mach/mux.h>$ d' X$ s8 H/ v2 v, J! }
. p1 Q9 w |4 @* R# _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) v) F* u& y/ S- H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 o1 U! Y2 a( f5 N) _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 Z5 j5 ?% M6 f1 g; d! r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" c5 O9 E, |: l1 l6 w6 P6 z
' n5 u# n8 t( y& |! N/* assign the tl som board LED-GPIOs*/
& T! u v5 D8 R% ^7 }static const short da850_evm_tl_user_led_pins[] = {# u) G+ H# R; @8 w- g' C
/* These pins are definition at <mach/mux.h> file */
. r6 O4 h4 `8 W& t# {4 A2 K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ N; B; A6 Z; n: f" [ -17 e. P) F J: l; o; [+ [
};' h" J: n0 x4 N, f4 s
0 ^( q% ~4 ?+ W9 \$ S: w& Z( [static struct gpio_led da850_evm_tl_leds[] = {. T$ J8 g: W0 W5 I0 t
{* W" U- X }; O. _* U
.active_low = 0,( ^( O; c2 B) Y& w' I) ?2 |/ [ Z, D
.gpio = DA850_USER_LED0,
) [; [" W: q7 b8 B! A6 ~ .name = "user_led0",
7 J; i; c7 L d .default_trigger = "default-on",4 C) B* B T, }3 o. N* W" F- k
},8 X; R" ?; T: E+ f4 T
{' a D; j+ c9 I9 m
.active_low = 0,
V# M$ t$ p% S, a+ J e" I" V .gpio = DA850_USER_LED1,
3 n" J5 z. {# g% G7 w0 W4 w3 c .name = "user_led1",
2 a' r* I- i2 f .default_trigger = "default-on",) Y" R! D: B7 b" j! b
},
5 j4 o0 I% y0 V {
& w1 N0 q7 ]7 j. _# `# P- H& E .active_low = 0,, y- v3 ~: R2 I# Y0 a- l k5 h2 V
.gpio = DA850_USER_LED2," O6 R1 v& c6 ]" }7 ~/ l" p
.name = "user_led2",8 B4 e/ F8 T: c5 [
.default_trigger = "default-on",1 E! i% V% a! s: T
},% [2 O, {0 \# P; h7 s
{0 b @* Q# m- @/ H# z$ U# m
.active_low = 0,# x% L- ?7 i+ x
.gpio = DA850_USER_LED3,# l+ j* i/ [+ y& ~- a( u
.name = "user_led3",
. H! o" x9 F5 u8 q* P .default_trigger = "default-on",
5 h! U6 ~- P5 {+ ~; y* R8 i9 V. q },
7 U/ v% B+ l# q7 {: }};4 ^- a$ q$ |5 {' z
$ ?, U$ d r6 ^3 t) {. ^0 \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 |7 s X, x' [4 q .leds = da850_evm_tl_leds,
/ H3 |' p6 ^4 a" \0 z9 y" T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& y2 F) c1 z2 V3 h; N* I! }1 ]
}; J( J. J5 N6 o/ ]* {. L9 g
. p- \& b$ ], x. H+ l) a
static void led_dev_release(struct device *dev)( A. B) g. x6 Q2 z% |
{/ m2 m2 M6 I* |: p$ U2 M4 M
};* a1 ~/ f7 N; U/ E/ Q+ ~
) O2 W4 p- x h qstatic struct platform_device da850_evm_tl_leds_device = {2 A2 g3 z* k$ }5 _' R) o5 U4 R
.name = "leds-gpio",
+ r1 g& L* [ l; X: Z/ u .id = 1,! ]+ ~9 t) c. L, E* p$ G! Q1 I
.dev = {: V! j' \) g* U
.platform_data = &da850_evm_tl_leds_pdata,/ Y# T4 |% i9 e+ d
.release = led_dev_release,2 ^5 ^+ J1 @! m$ T
}
" E( ~! b* Q3 G+ K1 k% l};
8 }: T/ G* K# ?- P7 x6 j" j2 O7 @& _7 X8 Z3 C
static int __init led_platform_init(void)1 ^3 [4 z1 K5 X/ ?
{* w2 e S( l; u9 A6 u
int ret;
5 B! K/ f1 t% L/ i; [" f#if 0
4 D1 U# \& l& F5 D' y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, l* _: A+ z4 u' T9 Q+ D* Z' m if (ret)
% u7 V4 ?" J( \# F+ p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- s6 F7 u9 X& l0 D0 m "%d\n", ret);
$ O0 ?4 [# t" S# ~& S* P0 i+ I7 K4 B#endif/ }) k4 H, |6 g. X
ret = platform_device_register(&da850_evm_tl_leds_device);7 U2 g* H+ I: \, k
if (ret)) O5 o: D$ ?- G% Q: d% J
pr_warning("Could not register som GPIO expander LEDS");% H& Z8 g; |% W
else
/ I& ?/ h7 {5 a printk(KERN_INFO "LED register sucessful!\n");
" a; u& `8 Q/ A! R: { c5 \. ^
\% Y9 f2 x Q return ret;+ Y8 q9 ]9 H( ~
}
5 w1 G( h+ Z1 w+ {# t: u2 ^. G+ N, M- l! m
static void __exit led_platform_exit(void)
5 P% v) K. Y1 c# ?! B1 V{
- X6 z* E1 X4 B platform_device_unregister(&da850_evm_tl_leds_device);
5 z, d$ w1 S2 L8 x
+ n. ^' G3 f, v* u1 L printk(KERN_INFO "LED unregister!\n");5 b% W: c+ A" H+ _1 x
}8 n0 X! v1 |# L
2 c a8 z% n7 X: L* h1 U
module_init(led_platform_init);
8 W3 x' B4 j: X Z( k Z0 q+ y3 `module_exit(led_platform_exit);7 V/ ?! m9 n6 k9 F$ Z
( m9 H2 O b- Q# T; J3 ~
MODULE_DESCRIPTION("Led platform driver");
6 d" q) s9 N# o, ~6 M ?; ZMODULE_AUTHOR("Tronlong");
" ^3 l1 P7 j9 `0 W1 D8 o" J9 ~MODULE_LICENSE("GPL");
8 a2 c4 ?! A) p5 J6 q7 @0 C
4 N" @1 ?" U/ a' I: \! k& Y |
|