|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! R1 ?' C1 x, w5 f#include <linux/init.h> M, n8 Q0 m1 d* H" |9 a& M
#include <linux/module.h>
6 r$ B" w( ?7 q; x#include <linux/kernel.h>9 r6 ^& y% W$ @8 _: j
#include <linux/types.h>6 Y g8 L4 ^ B
#include <linux/gpio.h>
7 {4 r* ]- `9 U( X#include <linux/leds.h>, v1 f6 K1 b! a4 x' t2 y% I' {
#include <linux/platform_device.h>
: w5 q' I! A- }* Y# C: Z$ q9 z1 S' k0 Q; v
#include <asm/mach-types.h>. N; F3 v* C, l9 l
#include <asm/mach/arch.h>5 C. F( D9 Q, f9 c3 H) i3 N! Y
#include <mach/da8xx.h>+ ?" j5 P# r0 ]% F
#include <mach/mux.h>( W/ ^- ^: L0 S. P" u) v
5 y3 ~4 N9 F2 M9 b* _1 o3 y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& w7 ]9 ]5 E" k; Y& w3 z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 X2 }! _+ }' L9 A$ w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: \/ @$ c$ E' v, r$ z; l#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ I% |/ g1 v* g* M) @
$ l* I/ j1 _# _1 v% s$ s/* assign the tl som board LED-GPIOs*/
$ g, \& U" T4 R. d+ `9 U$ q0 i! gstatic const short da850_evm_tl_user_led_pins[] = {
# h# V9 T+ U' C. x9 B5 b3 q /* These pins are definition at <mach/mux.h> file *// m+ S1 K5 S6 T U. w3 I. n! S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 e5 x$ r* G; ]. t$ L" W
-10 |4 }: x4 l. T7 U7 C
};
- V+ ~5 r' V9 J( w- D$ k
1 A7 q: X, c7 s6 L) z: [3 Ostatic struct gpio_led da850_evm_tl_leds[] = {
% k5 |/ X5 d V, x1 T( [- I; ` {
- M* m" ]9 Y, d .active_low = 0,
; E' A, ^* o4 v: a8 M .gpio = DA850_USER_LED0,# d" n) l" Y* a* m. M
.name = "user_led0", A$ u- ?7 Q( y1 Z) d
.default_trigger = "default-on",5 Q- f+ [1 p% a. Z! e3 {# t
},: X2 J% ?! K5 `; c3 q
{
) h" _1 \1 H$ o. [2 ?6 \ j, }+ U .active_low = 0," m; _+ v( X0 W: {2 _( m6 t+ E
.gpio = DA850_USER_LED1,
# m* b6 F* r# l# h* d! _% h .name = "user_led1",* |6 m8 I" S& e6 i$ \4 A
.default_trigger = "default-on",1 M: F. N4 j* A4 C7 E& p# H
},3 {5 u& x* H/ U3 x" F$ A5 A
{
& Z9 d( w7 [. o* l .active_low = 0,9 W: z/ L+ p9 x
.gpio = DA850_USER_LED2,
% G! y9 A+ v) R .name = "user_led2",
8 v+ _8 w7 ?1 T5 n1 t# K; t .default_trigger = "default-on",
& d. T! z0 {5 K- h5 }3 F },
1 v4 [$ t% P6 ?7 N. q' ]9 w {
7 A r/ p# n1 f4 g .active_low = 0,
! x' }" a9 Z, m( T! I3 ?% l) X .gpio = DA850_USER_LED3,
0 x& _+ l, n6 f5 z) Y$ ^( o .name = "user_led3",
" ?$ Y9 [' u( U4 K l$ x3 ], H .default_trigger = "default-on",
) _& C, |. {# I+ }8 r },
+ V/ Q! y& g" _# j- D9 R7 V};
& `6 E/ }3 A. M$ A* Q/ x5 s7 N) k# V* {& e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& F- P, u5 W3 J7 {! P" s( z
.leds = da850_evm_tl_leds,! r" {% |( Y0 q) [% y" z" [
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),% X, k u. m$ E5 L: L4 T
};. o8 h7 D* M$ o0 {0 E* Q }
9 B0 B1 p( p! C8 wstatic void led_dev_release(struct device *dev)
}0 \" \; G7 o1 W+ w{
2 r5 U9 e; D! V$ a' T7 R6 |; G};
, b! G/ I5 J# V2 j4 o$ e4 u$ J
% |. t# O) R* {% Y3 Q" n" Lstatic struct platform_device da850_evm_tl_leds_device = {
0 V) Q R, p2 \5 n* ]. C .name = "leds-gpio",
" P" k0 Z' t' C6 { .id = 1,* q1 y3 s: o' S$ [5 |7 R, g( d* b
.dev = {$ f# ?, o. F+ R
.platform_data = &da850_evm_tl_leds_pdata,
$ J0 h- F9 @" a4 { .release = led_dev_release,
2 N4 r4 ~, Z& z5 Y }
: c- C+ _/ u6 s& v};1 l/ q; p }! w0 U( F8 c, v& D9 d
; i$ j ~) y8 f8 O3 K
static int __init led_platform_init(void)0 i2 |/ m. O3 S: Y
{( o8 e Q, f! e$ k2 @* U5 p
int ret;/ l; m+ h5 K9 X' m% D+ k. z
#if 0
# j$ ]" b7 u9 \3 }: |, d, L ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: u5 x; X7 d' y, l- e+ S if (ret)
$ w9 G+ {* d( h" b- {6 o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; G$ }$ |: ]/ u$ M7 D6 `
"%d\n", ret);: Z" C8 h4 i4 i5 {$ S9 r" X G
#endif6 p1 L1 D( @& Y) w
ret = platform_device_register(&da850_evm_tl_leds_device);
& E3 h5 c$ N3 S2 l) l0 x, k1 Q if (ret)" s5 {+ W% a. R- g3 S
pr_warning("Could not register som GPIO expander LEDS");6 P( d0 ]4 b( Q4 |: h
else3 U( t4 W' ~4 l8 g7 B
printk(KERN_INFO "LED register sucessful!\n");
& c8 t; H$ m4 `' Y& d6 U1 G6 v$ A0 P3 [
return ret;
8 a7 k1 p& U6 r" q% t% N k! X# `4 o}- a; x8 N+ ]6 T7 o& X" q; u
3 d6 b2 t4 D" Y) `8 `" t
static void __exit led_platform_exit(void), `% V; I. W5 X- R) Z
{
# `& P! A6 h* T: l% n platform_device_unregister(&da850_evm_tl_leds_device);; q# e8 m2 N4 M+ a
& ^2 }% }2 C. }9 V0 o$ C
printk(KERN_INFO "LED unregister!\n");9 I+ S% O) r. K, x6 [
}
' [& Z5 B; }; B, B5 f$ B5 m8 h# i4 E" a1 t# ]: ^
module_init(led_platform_init);
( n5 k- N2 C- T1 i [* xmodule_exit(led_platform_exit);6 j. l$ _0 v' |# ~, j. }
. p& f, M: x' b* H+ sMODULE_DESCRIPTION("Led platform driver");
4 Z# h# j, I% m* D3 y" s/ H3 SMODULE_AUTHOR("Tronlong");
) f$ g: M3 N+ Y9 F8 nMODULE_LICENSE("GPL");0 K) O: T; @+ |3 g7 L1 D
1 D: O8 A9 G" Q7 ?; I' t
|
|