|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, w( c; ?; e) `& v#include <linux/init.h>
" A g# t) G, c- K#include <linux/module.h>9 H; T. X( K. H; E7 s9 c9 e7 B% U
#include <linux/kernel.h>
# M/ B# G( w/ n+ ]5 e#include <linux/types.h>
! Z d" D8 ~3 t2 C- p1 i0 i" J" }8 b#include <linux/gpio.h>: b( L+ ~: ]# f! l
#include <linux/leds.h>1 l: ~" V7 A X9 h0 |( S4 r
#include <linux/platform_device.h>/ B! R5 j1 m. G' b1 _) }
' ^2 b$ M$ {8 d1 X#include <asm/mach-types.h>
$ S/ y: d9 k3 i" t* Z0 r9 a#include <asm/mach/arch.h>
8 X( y* K0 F5 K- A6 I: ]# ~2 Y* E% Y#include <mach/da8xx.h>) ]8 a9 D/ f1 c3 L, f
#include <mach/mux.h>- P9 T5 G& Q, @, [
2 E& U E! ]4 O
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- c7 `1 B) T2 Q- H6 D% C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ r3 m! U0 F9 g& m0 K#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. h3 S! T& f+ d#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
D# a; R* k1 i- u4 ]8 T7 h! d
2 [, w# K1 H# |/* assign the tl som board LED-GPIOs*/
1 `1 L( ~ U ]+ M* u0 q3 sstatic const short da850_evm_tl_user_led_pins[] = {
/ R( d2 G7 N! M /* These pins are definition at <mach/mux.h> file */& V. ~6 P2 o9 z' ^7 s. a$ E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; O6 f4 f, ^8 A( s, P# o2 G8 }
-1
& f( G% F4 j7 X {; \% N};
$ V+ ]( J6 y7 h' ~& [# ^+ b, D; Y& r4 B K8 a
static struct gpio_led da850_evm_tl_leds[] = {: g2 |8 B7 Z( M! B; a; C
{
I4 o. I$ k5 m0 Z1 F .active_low = 0,
8 P: T% a" g, t; v' J .gpio = DA850_USER_LED0,# P/ P4 I1 e- q- w1 x1 [. i/ U
.name = "user_led0",
( n. f7 K# r' t2 D% n9 ~0 @; q! y8 j .default_trigger = "default-on",+ H( Z3 F! P6 i" Q8 h! ?/ e
},5 }6 N7 m' a$ h1 ^; I7 E1 M+ q
{
- q# Y' V* B2 h) Z$ P .active_low = 0,
6 f- A" r9 n" h% g; t, i6 K2 p N3 m .gpio = DA850_USER_LED1,
4 \2 [8 k) C! C* V- l1 J% \ .name = "user_led1",
. B9 c% S7 d- m7 \3 U0 M) ] .default_trigger = "default-on",# w( A7 G; _% Z$ S2 o
},# l5 V1 f4 m) T1 E( h M5 H8 |
{
- o( P- j6 C. O .active_low = 0,3 m% _. A& C. q5 _% Q% s
.gpio = DA850_USER_LED2,- M! _: ]; G3 A) {3 T: ~' Q
.name = "user_led2",
# e* U, s' c& Z# K, A6 {* q* X .default_trigger = "default-on",8 q6 h. k% A4 j9 F" C& h' v
},7 _1 u1 S) F5 S& e8 Y9 }" P6 x0 s
{
; i1 f& F! m; {) [3 z& L7 {6 F% y .active_low = 0,
7 K6 H8 ]# J6 z* h4 C .gpio = DA850_USER_LED3,- a2 _) \$ \' \$ K
.name = "user_led3",& U5 a* O ^1 u. m4 O) }
.default_trigger = "default-on",% j9 w( m1 c) a
},
3 |+ A7 N7 r+ c# c& L! l' d};& M7 T. x0 `- ~" C7 q, F
' V& u: I# d3 P& g& Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 e& O. p3 R- P7 V
.leds = da850_evm_tl_leds,
" \ l9 H& P2 K. q6 W .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 i: J. B" [# @8 ^% @4 u};7 o. g: E0 W3 d$ g% a4 H
. H' e( q* A. v2 D5 V( s
static void led_dev_release(struct device *dev)4 k+ u7 `$ j8 Y0 Q
{; U: [/ u6 @& ~( i* K/ N* p
};. h: B" ]. D( G( c& {- i6 r
4 G' {7 A/ ?# ?# S; ?static struct platform_device da850_evm_tl_leds_device = {& }$ c C! L7 J
.name = "leds-gpio",5 J e$ i* ~" |8 b. Z
.id = 1,) z t' Z& ^1 T: C3 C0 z
.dev = {+ H+ N7 g! n- t7 a& R
.platform_data = &da850_evm_tl_leds_pdata,
# E& S5 @6 d/ J9 y: X; l .release = led_dev_release,1 [1 \- [5 e' X/ \6 u: H T
}7 @8 {# O& Y7 C* z8 e- V. j; J
};! h; ?( z/ ~& D+ v* L
( w# g' N0 U' t& o4 X. V1 { O9 Istatic int __init led_platform_init(void)
* V* R# h: x. i/ Y{
2 x* X4 _7 O2 P( H int ret;
D' G6 \" t) E* ]) A3 \#if 0
+ c( j; V# R' P; h% Z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, d4 u2 I, N: s if (ret)+ f* J/ s/ V- t9 ]
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! U: q1 K" z, U4 H
"%d\n", ret);
# r/ W V4 }+ F7 O2 z% H. W9 L+ t5 G#endif
/ G3 S d4 F: e: K: b ret = platform_device_register(&da850_evm_tl_leds_device);
) G$ u9 g7 l6 @* m if (ret)5 o* j, X4 m! k+ {/ V( }. z$ q$ q6 A8 T
pr_warning("Could not register som GPIO expander LEDS");5 v% y8 H: z8 q0 }, h( j
else
6 [# ^( Q" ^$ o M( g. k printk(KERN_INFO "LED register sucessful!\n");) q0 m/ `9 _4 g& G: {
0 G5 m; S3 q! N' h
return ret;; v! ~& Q$ O& d* T6 y$ @
}% X- K( l0 R& K1 B
" Q$ N; I+ U: K, y. o# c3 d0 S; i% [1 Ostatic void __exit led_platform_exit(void)
?7 E# H6 d/ b' Z; M{/ D: q: N# t2 l. ]
platform_device_unregister(&da850_evm_tl_leds_device);
; ]- [) |& @4 C! Y7 C8 R9 @
! a" p6 f: ^ Y, {0 ~' e printk(KERN_INFO "LED unregister!\n");: S+ }: o. B- Q6 B* H( y% i
}, j; k, z: \- w" `' a2 F) t
* b% H( B J2 k! H4 g+ [" lmodule_init(led_platform_init);
8 Y* `2 ]) t8 ]; Y" k/ ^module_exit(led_platform_exit);
4 f0 z+ m3 b3 X! R2 ^0 u2 v( W$ P& C I9 j; r* i
MODULE_DESCRIPTION("Led platform driver");5 @3 V9 `/ h7 T* d! }" S" [
MODULE_AUTHOR("Tronlong");
& B E4 f% Q1 b1 T. d, xMODULE_LICENSE("GPL");! b. |4 p$ _8 A! n$ R, f# h% H. x
% w( u; s% q' F- I7 ]" R$ [- G
|
|