|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, y1 `1 X# k9 U8 ?#include <linux/init.h>
4 i, k8 c8 {8 l# m Z& B#include <linux/module.h>
' Q4 W# Q! {# j8 n0 M#include <linux/kernel.h>
8 c8 |8 c5 \6 `" r6 _. g#include <linux/types.h>: G6 N; I2 V8 [5 p2 {( ?* U
#include <linux/gpio.h>& s% A* j9 R& V5 k) `5 o
#include <linux/leds.h>
% \2 f/ i$ ]. d#include <linux/platform_device.h>
+ D( S D. _0 r7 H- C
& b( C+ q" F( `/ {& A1 u1 e#include <asm/mach-types.h>! G. c+ v! X1 G6 | v; \
#include <asm/mach/arch.h>
, m8 n1 I X/ ?5 X$ p7 F: {2 c#include <mach/da8xx.h>8 g# h, `2 a T2 P
#include <mach/mux.h>" r8 b9 |! F5 {
- [# a) L9 c1 x- w, v) J4 g
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) p. B! @$ s& ~% [3 F
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 B% e; q& ]2 Y5 J#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 K; l8 F8 g% g1 a1 X' X$ m#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& M$ `; K9 O- ?- [
& F: Q5 Q( I2 I4 l9 K, {9 w4 ~
/* assign the tl som board LED-GPIOs*/
$ a1 Q- i( }8 d, M& z5 Nstatic const short da850_evm_tl_user_led_pins[] = {' f! N* x7 E/ f6 V( Z
/* These pins are definition at <mach/mux.h> file */
+ L; U9 H% _6 t0 y. l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ t- J& p5 \# u+ V
-1
/ S* T, Y, u7 l* k};9 W3 T8 q( v( N( `
) f+ Z' @, h& N
static struct gpio_led da850_evm_tl_leds[] = {
$ _, Z4 e, B! J0 k$ V$ z7 ^ {
) m4 } M; N1 M e3 b .active_low = 0,9 M# n6 |; {0 Q) q$ T5 p$ C# ?* ?2 V
.gpio = DA850_USER_LED0, D5 z1 E5 w3 k* h5 `0 L& m; C( y
.name = "user_led0",0 O) T ^4 \7 Y) D, o b
.default_trigger = "default-on",. F- B) r) W5 h/ [. r8 ]! R# G
},* I# z5 U5 ]- ]
{1 | s1 x9 n/ F! b% j4 A
.active_low = 0,
. `- D8 i3 p5 y7 d/ k% t .gpio = DA850_USER_LED1,$ B2 _8 R( Q5 q$ L+ A1 T; m
.name = "user_led1",: c8 X( x1 H6 ?7 D/ J+ G. _9 J
.default_trigger = "default-on",/ }/ U2 ]4 B0 h7 G' L! U6 R8 n
},
; V" G. O( e- Z( [& K3 j$ Z) b5 W# Z {
! X/ U- e; ?2 N0 r .active_low = 0,$ I2 y6 Q9 {+ ^ o
.gpio = DA850_USER_LED2,4 h& R: G! X1 n' n1 o8 c4 s4 j, b
.name = "user_led2",
0 H9 o, A1 r0 R3 ]% l& w+ j& s .default_trigger = "default-on",
# I7 E1 [) M. S& Z% P ]8 F" |/ u* j8 h },
3 s* ~* U" e) x {3 N6 ?, j7 X, k) |* _2 S
.active_low = 0,
& D, T1 T N/ h3 v3 e; j .gpio = DA850_USER_LED3,8 o; ]" ~0 j( }
.name = "user_led3",
! f. R; K5 S/ `/ ?7 D9 g .default_trigger = "default-on",
- _4 g; _: }8 o Z0 v9 Y },% B' \5 Z% {% e) `8 u+ m1 e3 m J
};+ Z. ~; ^! z5 n: p( e, K) o- w d
6 ?6 z0 k! I# Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 J" _: Z1 ~4 x4 o0 Z .leds = da850_evm_tl_leds,
* D& f+ X/ C! t( F- g3 Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 |' z/ u& O+ D H1 ~; U};( c8 g: a& [6 k' b
+ F) s" L' o3 D
static void led_dev_release(struct device *dev)7 f0 ]5 V. d( ]; l7 u
{
- F( B+ Q/ [" b+ s5 T- W2 ~};
$ ^4 T$ g* Y" @! e c: B# S
~0 ?% U0 M+ n1 Q, ~; e2 G0 Astatic struct platform_device da850_evm_tl_leds_device = {) e1 n' C( N, H* x$ ^' y, h! V; x
.name = "leds-gpio",
/ H( I3 p: t; d; q: a .id = 1,& f* E* p3 M8 u( g; e
.dev = {( p5 l; T0 P$ c1 M8 \( g
.platform_data = &da850_evm_tl_leds_pdata,
% w- |1 T( _% i$ V) g3 d .release = led_dev_release,
+ S/ Z( ]7 d* h6 r }
6 Z3 P. g3 k# [1 f) W+ T};
. H. I2 o* ?( J0 s% A1 a o2 M1 j5 ]3 W! p& l4 ~2 |
static int __init led_platform_init(void)) k/ V, [: m. ^/ ^! v: c
{
3 L* B( _# G1 Z5 v$ U! P. v int ret;. z$ Z* i9 A! {7 w) e
#if 0& X* E( X' v( o1 p) o3 t. J" I
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 _6 ~" A& t# o& b; W% H if (ret)0 H* Y c& O5 e7 O0 J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
F$ u/ R/ c( M6 e ^ ~; ] "%d\n", ret);* x6 K6 f; ^# ^( C
#endif
, Y% R/ h2 v6 a% k0 J ret = platform_device_register(&da850_evm_tl_leds_device);
& w& J8 L: T" V9 M$ l if (ret)3 d! G0 K0 c7 f! k
pr_warning("Could not register som GPIO expander LEDS");. N! N( ^% m' b* b# B# j
else: d* N% f9 a, i4 |' g0 A0 b. p
printk(KERN_INFO "LED register sucessful!\n");
; h; @5 f/ V% W2 h' w: O8 f0 U+ [- J" I- r" r
return ret;
! ^* g( n2 g9 t4 C2 B" D) ^}; P* I5 k% s$ x1 Q( h0 p9 N* t
' u# r7 y, G, U" E8 w/ _static void __exit led_platform_exit(void) B- v4 k% w& }% I9 `# X( L
{
% U7 t0 X; K% ~2 F3 L platform_device_unregister(&da850_evm_tl_leds_device);" k. Y# z0 \# Y
& K' a9 v: `8 J# Q$ x
printk(KERN_INFO "LED unregister!\n");
, C4 T9 a( t6 ^- h' ~3 u}
) k* i9 C2 X; |* r% ~
+ Q2 c3 L1 u2 P4 b2 u( u, v) F4 Imodule_init(led_platform_init);! u! E8 C8 Y3 D7 N* ]2 V' y9 R1 G. c6 q
module_exit(led_platform_exit);
9 G( y; J% r* U8 O" k! I3 y# ?% F& N$ B: d7 k
MODULE_DESCRIPTION("Led platform driver");7 C: o# C0 Z: p
MODULE_AUTHOR("Tronlong");
/ L Z$ k, T ~ @MODULE_LICENSE("GPL");
1 ` U" _/ g3 w% f/ }# a
5 c ]6 }* p: y$ R6 S: l/ L% A |
|