|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
y' o( T2 R: I: v! _+ D#include <linux/init.h>
9 {( q( K4 D$ v3 B: M& k2 u#include <linux/module.h>
7 E/ r2 ~! M6 g#include <linux/kernel.h>
3 s2 n5 H2 I/ g1 r5 J0 w% q$ B" G#include <linux/types.h>& B5 X E* R7 U& }
#include <linux/gpio.h>
) T/ a$ v- D5 K {) Z! d$ Y#include <linux/leds.h>
3 D T+ g1 D, I& f#include <linux/platform_device.h>
% k, z" ^, k4 w, P0 w/ K
; e# H; C) A9 u! d K0 u. U#include <asm/mach-types.h>
' {1 e+ E$ B0 x' z5 U; T#include <asm/mach/arch.h>
% i/ g2 ^) n" D" N& H) h) c( z3 C#include <mach/da8xx.h>
5 [2 U- t- J( m% i3 H3 L#include <mach/mux.h>
: A' l% ~- ~6 H |! F# ]# \' F6 K$ q% K' H5 }, f& H4 M- P/ |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- H8 ^& u5 Z" |5 V3 L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 k3 N% I$ ^0 k7 _# C3 _7 \; `" r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 k3 r+ N( \6 J8 F) x0 N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): d+ }4 Z9 l. F* W0 v: ] m
, d3 O$ ]3 n8 y# s2 z
/* assign the tl som board LED-GPIOs*/# c; n% k( g( n
static const short da850_evm_tl_user_led_pins[] = {
0 T$ A8 o3 _% |/ b* {2 l9 ^ /* These pins are definition at <mach/mux.h> file */: l+ |% `/ {% F8 }" ~, K" m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 i4 y M! p9 `( z% Y! K( d; e& _
-1
9 }8 p" l1 N; h( U# G+ Q};* N( \; E% q; p- @
( z( E R" z5 ?, f+ \$ X0 p
static struct gpio_led da850_evm_tl_leds[] = {' X1 m1 Y6 Y- @* D1 u5 V
{
0 S% \& n1 ]4 z) C0 G; P .active_low = 0,
" P% Z: s3 g f% c# K) D .gpio = DA850_USER_LED0,5 X) i+ P @3 o& `
.name = "user_led0",
+ e8 j; f/ H0 g1 L0 x* o( f( u2 s .default_trigger = "default-on",
" B% |3 S( d4 N+ \3 |3 ? },
( T8 U! u$ ~8 h5 K' b {( |5 k' g+ T, [; F) j& M9 k
.active_low = 0,
7 |6 |! p# f, m0 z4 U! m .gpio = DA850_USER_LED1,1 [# n6 h7 a! W5 Y: i* ] L& ^+ L# X
.name = "user_led1",. k5 P+ v, P& w/ e* z L
.default_trigger = "default-on",2 M9 V8 v3 r- m, W* m4 N6 _) @
},
. M2 v( P2 S* ~$ `$ }4 R) g& u: b {
! q$ G: x* E3 B* d9 { c' {& W .active_low = 0,
1 @& V8 g2 d6 C k .gpio = DA850_USER_LED2,/ c, G( v( a1 c1 T5 |* L; e! @8 d
.name = "user_led2",
: p0 f' J* U/ i5 [3 L .default_trigger = "default-on",
+ H/ Z- O7 t1 r2 N% Z7 A; B },8 n b) N8 M9 l- `; F! |3 e
{
7 H! u' M3 l6 m3 L* [" Y8 F .active_low = 0,0 I7 }$ }2 i' ]0 S9 V: ?/ }
.gpio = DA850_USER_LED3,
2 s; ~, U% [2 o% y8 E .name = "user_led3",# c# |8 L$ q6 H
.default_trigger = "default-on",
: {6 l7 g# Q+ \% |1 A },* I3 I( I1 a) n3 D% }3 @0 u: a& q
};' A. Y, D. D% _ y0 t. e. x, u
) }! n0 ?/ ~# x0 V+ {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ S. a$ ~% i. e7 s8 p
.leds = da850_evm_tl_leds,: V% ]/ z+ ^4 b# h- }3 g3 S# q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 R9 O3 ?9 T) U8 y6 l};
* d* m Y) e) Z" a. x
' D0 m, u. B" n% z( p$ O% C# H$ Bstatic void led_dev_release(struct device *dev)
5 K# r) j: {9 f0 g! u{- p* e; }9 @- Q: k
};# h8 b' `6 A9 B1 V0 y6 q- X" G; ~
, ^, {/ i7 Q @* [. _( a, u
static struct platform_device da850_evm_tl_leds_device = {
) i) Y1 p9 l' {( I$ Y4 n .name = "leds-gpio",3 G, T) ~+ V. [4 s/ _* D
.id = 1,
( a& l" u9 ~& b% U% f% V# ~% [ .dev = {
& f5 a! P3 Y. T5 L% P# c5 e .platform_data = &da850_evm_tl_leds_pdata,6 i7 z- B2 X P3 |
.release = led_dev_release,. C/ q5 m3 d H% M9 x, J
}; ?0 {! ~1 _- t- W+ i
};
; [2 h0 L/ {9 |( Z* l- L7 i9 `! k( i( m
static int __init led_platform_init(void). w$ \* e4 g+ J1 A X
{
' W% S: z, J6 U6 a8 v' _+ S int ret;& T; [6 z7 U/ j) p% }- x
#if 0( G! k6 s" _- n3 d& J& b: D( q7 s* Y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 a3 l# s C) Z if (ret)" ^9 y; z0 g1 R- F; a
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ L( x7 Q: ^( [8 ^' y" t
"%d\n", ret);: G% ~+ z$ R% T' m% U% ~2 y) S
#endif
* T* i4 }7 i, i0 N% X ret = platform_device_register(&da850_evm_tl_leds_device);9 c3 ?( H. G3 p+ _; H( d) S
if (ret)' I! Y8 O/ M: W$ E
pr_warning("Could not register som GPIO expander LEDS");7 \" b* ^2 A7 s* z0 T/ n
else
# Q( o; ~+ i2 i# k! w/ K$ Q printk(KERN_INFO "LED register sucessful!\n");$ Q4 A$ p$ s& `4 E4 I5 v
+ d4 ^1 j$ J$ ]/ d2 h# y4 v( L1 u. T
return ret;: Q9 C' c* W. L' w1 X
}5 M# A- V0 a7 s( Y4 v
7 Q. Z( V2 B9 @8 s5 c
static void __exit led_platform_exit(void)& D2 U& H9 K3 _
{1 ^4 G9 Y5 \, D) s
platform_device_unregister(&da850_evm_tl_leds_device);
6 ?0 _7 y" y/ }! h: o0 v
+ q6 G! a8 m! f1 t& c0 Q. N printk(KERN_INFO "LED unregister!\n");
1 t M$ x: y& F4 i4 E}, ?# g( A/ h1 \ s/ r% P j& T4 T
( e2 \) i4 f. T' hmodule_init(led_platform_init);
9 `$ ?& q* F1 \0 j! m% c4 ^& Fmodule_exit(led_platform_exit);
~, [7 K. r3 [$ s$ T
0 k. l' x7 }. M* y+ eMODULE_DESCRIPTION("Led platform driver");% E3 h, ^# X' c
MODULE_AUTHOR("Tronlong");
8 v# R5 o+ O$ n+ I6 cMODULE_LICENSE("GPL");9 v* {) t6 ?$ v+ c' o2 ^; l
7 c# V2 h9 G; Y7 Q+ I |
|