|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# f8 h$ i1 V1 e* i0 @% J, K d
#include <linux/init.h> A3 \8 p1 m- ]0 }1 g5 z
#include <linux/module.h>
! z2 X5 x) u: ]; I) t; W#include <linux/kernel.h>
" U7 n( t# y( W+ `7 y: `) e#include <linux/types.h>$ R* h' ]* ^. [
#include <linux/gpio.h>" o- \3 d5 o p
#include <linux/leds.h>
! t* m" v, u0 H D#include <linux/platform_device.h>
- F" ?; O8 e, ~2 A. M8 n, A9 p( h6 x' @
#include <asm/mach-types.h>4 G( i1 h. J; t0 i* p
#include <asm/mach/arch.h>$ g$ N6 u. Q# ~0 _' n
#include <mach/da8xx.h> J! D5 P4 n9 T$ B
#include <mach/mux.h> X- w0 Y% ?/ s( f' b8 u$ g
8 O7 c3 f8 N6 v X4 N/ A0 O! q; G#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ u% k# D, x( W9 v9 I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 N/ d+ J4 |+ ] D+ R1 }3 @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 Z8 o4 s2 \& }8 r0 r# }) Z h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! T8 l* m+ r2 j( {- G6 Y* O, W7 w) r) r4 O% @
/* assign the tl som board LED-GPIOs*/& ~. B; g9 [- a D( Q- |( C! |. @
static const short da850_evm_tl_user_led_pins[] = {
" c# N0 e _# _2 U* p/ ?# ]8 L5 s /* These pins are definition at <mach/mux.h> file */
0 T" M2 ` u* k5 X: ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. t8 y- j( W. A0 q. b -1/ ~, S( k8 O ]0 i
};' y7 G& R" D( j0 e: s$ R
9 v* O) m2 l2 k/ @" t
static struct gpio_led da850_evm_tl_leds[] = {, L! B! ^- p; c, h* T. E
{
4 V S6 J) a8 g2 Z. | .active_low = 0,: B& J, [$ w/ I2 J& s; f: d
.gpio = DA850_USER_LED0,
& Y% I; u/ w# S v/ ~" F, ] .name = "user_led0",* ?: c! U3 _& q1 t2 o4 m
.default_trigger = "default-on",
6 l" s6 p; e6 V# U# K },7 h% I1 R9 ^6 g
{6 h$ p% S. P1 b' }) b$ t" {
.active_low = 0,7 e( \& D$ [9 ]! A. K, i* d
.gpio = DA850_USER_LED1,
% r/ Y3 T" Y9 D7 d, E2 g .name = "user_led1",3 i! k5 E- R Y5 b k2 x
.default_trigger = "default-on",7 f( q( A( Z) b6 S4 B. _ _+ w
},
, Q$ t G) T- p2 Y! J- l. [ {" q5 n/ n. G4 s' k5 {; f
.active_low = 0,
: u1 N" F$ Z5 i5 { .gpio = DA850_USER_LED2,, H& X* v' n& Z/ z
.name = "user_led2",2 c1 p/ H6 q4 }3 Q, y9 A4 c; T
.default_trigger = "default-on",( N, g, j( @1 `0 u
},
9 q$ p% `& T( } {
. d N$ H. p N5 a& _9 d .active_low = 0,
6 O) X, h$ ~4 V+ A9 C2 P+ t .gpio = DA850_USER_LED3,
" l5 ?. ^6 D1 \& x* `$ @0 i .name = "user_led3",
+ m. M" h& }( j; n .default_trigger = "default-on",
* D$ j! ^& L4 C },& t4 X; O2 p4 l
};/ X" z6 R2 E" j% a
- U: O; }$ x, u) N! f0 r& z+ U% P) X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- G( a) u2 O# V& J+ P# K! x+ A
.leds = da850_evm_tl_leds,
+ H6 Z! f5 N4 ]# O7 @ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 q1 |" O- d' a3 b. E( U- f3 R0 ?
};, {" @/ ~ ?/ W
/ a/ c; e, C( ]4 I# S0 K$ Zstatic void led_dev_release(struct device *dev)* E$ V* t$ m( y4 [: o
{6 S0 s- D% e/ C8 Y
};3 k9 N$ a1 Z, p$ U% @
& f' y' h) [5 O* l0 l) n
static struct platform_device da850_evm_tl_leds_device = {6 ?7 R1 R, _4 I
.name = "leds-gpio",$ G- b/ d+ N& \: h% h; T
.id = 1,, C- W' t6 G x0 ]% d( G5 `
.dev = {
# o: n2 n5 t9 h .platform_data = &da850_evm_tl_leds_pdata,, L# d) m& U* u8 ~
.release = led_dev_release,, w: s! D$ d6 J- t
}
) s* V' }& ?! l8 E* w$ U: F3 W};
1 U& H4 U$ a& e, ~6 d! @
' C; D! ^- d4 Jstatic int __init led_platform_init(void)
. v0 @. e7 m+ I P" w{5 U- `; J3 H" ~ H: k
int ret;/ v1 B2 D% v% a: N0 a# A
#if 0
1 S! N' i* \2 k9 r; q! W' T5 e9 m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, ?( W" p1 m: Y+ N( M
if (ret)) l3 G& f+ } K/ i
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* W" y' [9 x6 E9 j) X+ c1 e7 g. B
"%d\n", ret);
& l! a- R. \6 m- n$ O5 |#endif
- s5 e9 F$ k- b4 j ret = platform_device_register(&da850_evm_tl_leds_device);
( ]# v( Z$ q- A4 }5 ~ if (ret)1 L% n, z9 a; n7 M: N) W( u
pr_warning("Could not register som GPIO expander LEDS");
9 U y5 s B# }! W/ {! t- ] else
* S K0 g6 q' k1 n) S6 \+ Q printk(KERN_INFO "LED register sucessful!\n");
) h3 o: G/ C# D& A T+ r
& q" d" p4 Z4 `. l5 J8 S( K return ret;
4 \* ~% ~. i8 p7 P, Z) V$ k}/ I5 u( r2 B# `1 l) q: T0 e# v
- h2 _2 |; Z: {( Z/ ]; Ostatic void __exit led_platform_exit(void)
8 z$ I& q; R2 l8 X* q7 E% @{0 B2 M' E, s# n/ `0 B' @0 O
platform_device_unregister(&da850_evm_tl_leds_device);7 ]% s0 H7 k7 t
6 ~& v- e2 @ ?6 Q5 q* |( l. M7 S8 r7 P printk(KERN_INFO "LED unregister!\n");. c3 J: t- I! U9 l/ e
}
' s+ U2 r/ ]+ X9 Q
; V+ _* X1 C, r" D' z7 T* nmodule_init(led_platform_init);
& x! A* j' Z( b8 Y1 }5 X0 ?9 Cmodule_exit(led_platform_exit);
: c# w) V$ x5 k: E( w) m, U+ M/ p. _5 c4 |* O: I* y* r
MODULE_DESCRIPTION("Led platform driver");; C+ o5 ]$ ~; Q4 f \
MODULE_AUTHOR("Tronlong");
. ?2 t* M! H, N. f# EMODULE_LICENSE("GPL");
) A3 j3 J- f0 s% d# E$ }5 y; [' H6 h* q' E/ d6 m
|
|