|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, d- _4 c* D7 b% m5 p5 {
#include <linux/init.h>$ ^- ^1 @4 m+ `+ c
#include <linux/module.h>
( F9 a6 }& v; X2 |* Z2 Y9 i6 Q4 M#include <linux/kernel.h>" w3 U( n1 o$ [0 b
#include <linux/types.h>
7 N5 ?3 Y7 s" |) J3 K: r#include <linux/gpio.h>
+ `# q1 @$ X" u/ Y: m9 F+ b#include <linux/leds.h>& g X* i5 h! N; X6 }$ y9 [1 U
#include <linux/platform_device.h>4 S7 y# Y+ t; i0 z4 H6 O$ r) U
' u' u& p( l5 ~: U1 @
#include <asm/mach-types.h>
9 @( J! `/ x4 C! z3 Y# i9 `7 c#include <asm/mach/arch.h>
& u, Q" _, ?2 I( V#include <mach/da8xx.h>9 V- o6 |1 s# G+ T* p( z
#include <mach/mux.h>
0 L( @( D# K7 J& K6 W7 F" T/ C0 L2 ?. A2 `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( M! X8 U% B; J G9 }. S! R2 u
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 b) y. s9 R% s; c5 U1 u3 }7 g
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) R* L$ V' y8 j/ U6 }* o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# A6 I: `! f) J5 s# X" A8 q7 J. b& i
/* assign the tl som board LED-GPIOs*/6 S: R- y! G# u" G0 ?' e
static const short da850_evm_tl_user_led_pins[] = {& |, K( j) l+ G" H" U
/* These pins are definition at <mach/mux.h> file */
& }% m6 M9 v% c# } DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( l) w0 Y" u9 k -1, p+ w: j0 w- F
};
/ f( f& {. N% m6 s2 {6 k3 B
* f0 L+ {: Z5 P( @! ~+ }" ^static struct gpio_led da850_evm_tl_leds[] = {7 V A; [4 M, ~& {$ ^7 }
{
/ c+ U$ e3 O" u& }7 _$ X .active_low = 0,
# Z' r0 H$ P7 n) o3 P5 @- S' m .gpio = DA850_USER_LED0,
4 G) Y( }, O5 z# l" w) \; t .name = "user_led0",
) x+ H# D5 o3 N* G .default_trigger = "default-on",
! ~& c Q# I8 U. Z( ?, T },4 n& [" T0 |5 O1 y8 ~- n) @
{
% C- ?. h) V* ^. s, B .active_low = 0,/ a3 g$ _. W$ E9 d% w
.gpio = DA850_USER_LED1,+ M2 t7 U' f; v: O- W5 n
.name = "user_led1",5 W0 `! q& Q3 n/ i) ~
.default_trigger = "default-on",, {1 [9 H% _0 t9 [
},
Z6 O0 l% S% n5 m" u7 u; w% ] {$ i. E1 x% J# {3 p
.active_low = 0,
0 m- p1 U8 P- a) D d8 g .gpio = DA850_USER_LED2,4 F1 f, o- Z( ?5 J" }0 \/ f8 _3 ?- b
.name = "user_led2",
5 P) M4 B# r' [ .default_trigger = "default-on",2 y1 I, \8 b& l$ y- m$ p
},0 M. V" O* [! s7 L, E+ o+ ^' \
{2 R0 W# L( I5 J" a4 E$ M5 [7 b# A
.active_low = 0,: |1 y4 b# R9 P/ O% e# J% \, [. ~
.gpio = DA850_USER_LED3,
# t9 |/ s: F( I8 v: g: v9 Q4 w( W .name = "user_led3",# k# d9 x8 S; `* p, c
.default_trigger = "default-on", n E# L- ?4 F$ Q* J
},2 ~3 m- ], \; o( K
};! ]. T- |! {; U8 T4 t
5 Z4 x* F3 u% N% P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. i0 F7 K8 A# [( Z8 B4 `
.leds = da850_evm_tl_leds,
( e t! y. N7 i) ]! R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: r. y9 @" Q" V3 _* V! o+ x |2 F
};
) t2 a a" _3 K) v, I( {/ l: e! a2 d% m& F: f/ {
static void led_dev_release(struct device *dev)/ v! g, T7 I* y- \
{, l& i% `8 B" u
};
, b" M9 `8 U; [+ b6 w" E
7 P7 d' c, y, p# g% e* P+ Gstatic struct platform_device da850_evm_tl_leds_device = {
. S" Z& @1 Q! l* l) V7 j4 l, H3 W .name = "leds-gpio",. q0 L3 p1 s0 K. v' g3 N6 C3 E
.id = 1,6 L/ y t5 I9 p+ Q' S* Y- @
.dev = {
$ h: s* a2 c3 O& [5 j+ q+ z .platform_data = &da850_evm_tl_leds_pdata,
# n8 X, _6 a& y/ q8 O7 t7 p! Z. I .release = led_dev_release,, }6 E, R# G# g
}5 ^. C% T5 _1 |! Y
};7 f: X" r& b) E* W) t6 `
6 j( X E3 [) x3 v; { fstatic int __init led_platform_init(void)
; m0 A: d+ M, ?) k! `{
# l( ?& r$ i$ f6 F int ret;
2 { F4 Q/ b$ C# E4 I! e#if 0
& z' v; M% Q5 | ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# o; z& I7 |' I. O7 B1 v$ B E8 ]
if (ret). w8 O; p5 g$ T3 r4 F0 R, g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 d0 F1 B J! ]9 |6 C "%d\n", ret);
1 G+ F1 g; P0 f' j4 m- o+ G; M* g#endif
" ?2 c) B: D% p ret = platform_device_register(&da850_evm_tl_leds_device);
! @. ?0 X( ~2 r7 r; U' [ w if (ret)
+ f7 f4 r S: M: f pr_warning("Could not register som GPIO expander LEDS");; f1 b: c+ B9 s- [% F- p
else
6 ~ g, f% p/ n( } printk(KERN_INFO "LED register sucessful!\n");- b" _- \. N9 P" C
& b, r0 k/ |# v- A* ?' f/ e
return ret;* B* y3 X/ e" \+ d
}3 Q ^, l+ O, ]9 ?
$ a% K' C% y, [5 H) F6 F* wstatic void __exit led_platform_exit(void)* Y" B7 K' w# Q0 t, d) L
{
. |* ? _' A( i* L. f platform_device_unregister(&da850_evm_tl_leds_device); u% `' L% [3 Z" h" ^
' S+ X% j- ^1 f( P# S6 k" ?# c( X
printk(KERN_INFO "LED unregister!\n");
b2 R: b1 q+ W) u+ X, ~5 r}& x9 V" t3 ~5 P ` D$ v
3 K" ~6 S, z4 K
module_init(led_platform_init);9 c% w: C$ s% [9 ~: j) ^
module_exit(led_platform_exit);
% b4 z$ b) n0 G; v {0 x9 F6 k4 \* x" R* e3 \* S) w& t2 o4 G
MODULE_DESCRIPTION("Led platform driver");5 K+ D1 l0 C' Z5 u
MODULE_AUTHOR("Tronlong");
6 H) ]/ V$ o; P9 Q, X% d) hMODULE_LICENSE("GPL");
5 n J5 m$ J w9 j( F
# n- I% q+ D) A# J F: B$ |' @ |
|