|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 o5 a0 P0 R, P; E7 G$ ]
#include <linux/init.h>
% a6 Q) V$ B" u' e ]- Q8 P#include <linux/module.h>' c3 p7 \9 q' R( @* T% d
#include <linux/kernel.h>' L; W% N, i3 a$ i' E l
#include <linux/types.h>, z) }" ]; ]/ T
#include <linux/gpio.h>
* \% o2 J% I4 v3 Z# L9 w) C* f#include <linux/leds.h>8 h! y) D$ f2 l* v* l) |1 U; T
#include <linux/platform_device.h>
6 y* t7 J; y% C; l3 E+ ^0 B( g: U6 ]+ V/ _$ F
#include <asm/mach-types.h>/ r9 c6 ~5 a$ `4 S
#include <asm/mach/arch.h>
% T0 ^5 V) C( l# G0 @+ ?- C+ c#include <mach/da8xx.h>
+ q; f, g% E' m e% I! J#include <mach/mux.h>+ _) k, x2 ?1 v
3 ]9 F3 l, t, ~/ F! p
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), L% Z( Z5 E8 r/ {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 B7 f& M. N6 u) @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" D# W( r* I6 L' U3 L
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) G2 v; f2 X7 q s
3 e) E; d# F6 E) e& E
/* assign the tl som board LED-GPIOs*/$ D9 o6 {, h2 k2 K- |* }
static const short da850_evm_tl_user_led_pins[] = {1 _: n5 G, W: {$ d) E
/* These pins are definition at <mach/mux.h> file */- F- j" j8 P1 z" [! E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," }6 t$ F+ t6 `
-1
* T: V8 l/ [2 P2 A' F2 Z};
T0 Z) ]0 D. [$ h/ V o# Y7 \4 c O( @9 q( j
static struct gpio_led da850_evm_tl_leds[] = {
/ z# [: {! o; d, P; f. ] {/ ?) ^* ~4 a) s: ?* J, [& Q2 {
.active_low = 0,; n7 @ ~9 j1 [; I5 k a
.gpio = DA850_USER_LED0,
* T `2 C9 o) v( ?8 g- w$ v .name = "user_led0",
I: d* G0 w2 _; x .default_trigger = "default-on",
& C6 f4 J/ Z% l5 i0 H },
# E) L- u% W( t* h: o! b {
/ L* L% q7 q+ l9 ]* k7 o$ ~ .active_low = 0,
6 ?+ z# n' I7 g) |3 x" w& e4 ? .gpio = DA850_USER_LED1,
! J7 b2 V) E. I6 ` .name = "user_led1",
# b8 [4 i& t& P9 m, Y: j8 {7 \ .default_trigger = "default-on",0 X2 a+ p. I; L
},
0 o a" v) }1 i6 B; A {5 g7 K! g' ]0 S; N) M$ w: _
.active_low = 0,
; c) Q6 @8 x3 ~9 y) v2 R5 V* V .gpio = DA850_USER_LED2,
% Y2 ]" L I, Y, Y9 ^6 [ .name = "user_led2",0 K& R2 M; @ j8 y
.default_trigger = "default-on",
3 C; G9 D6 b8 U0 D) i1 q H# P# s },
4 g' O [9 k. k6 S; d& w* { {
0 _0 O: @# `5 Y/ G( a .active_low = 0,
) {8 P4 K/ [9 k% k1 ] .gpio = DA850_USER_LED3,# O. p6 n t' ^9 K2 S6 K& f
.name = "user_led3", n/ u- P: R$ x/ N& V+ r0 j
.default_trigger = "default-on",
2 s- o- O8 V5 o1 }! [ },4 E9 i0 W7 Z) K5 j, L+ M3 E
}; K a! a2 ~% @1 Q
6 b" n4 w# K5 I+ t7 [static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: M3 [; R1 ]7 u8 ~) S0 {4 Y .leds = da850_evm_tl_leds,/ p! Q( w* }8 C: U" s- v ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: I, b) Q2 _8 _' p
};, {9 W3 z* z! c7 S0 x [) J7 i
6 X3 E/ r3 F' m5 H& ~6 D$ _) gstatic void led_dev_release(struct device *dev)6 j( L% t I# [
{
; B \" }9 W% n+ y* I4 {};
) {3 Z; i# C' f/ q1 I9 O0 y( C0 }/ o
static struct platform_device da850_evm_tl_leds_device = {8 a7 r' E3 [' q. L, ?
.name = "leds-gpio",$ a5 D! o& C( c, S+ `7 Q4 V# C
.id = 1,
* f( u9 [: r" H) `1 h2 B6 l6 U$ m& Q .dev = {
0 U {6 w% c# {; W# h9 ?7 X* ? .platform_data = &da850_evm_tl_leds_pdata," A- H; a. R/ B# E% A" g
.release = led_dev_release,( x* w, X8 g$ T' l8 f4 L
}
3 j" Z# k8 Z0 K" k; P2 G};3 g8 `2 T6 X; n0 P/ \) Q# a+ w
& I# A! z7 q4 x2 d
static int __init led_platform_init(void)
7 ~5 s7 D% ?1 @5 J3 W3 w6 L* `{4 \8 n) q0 W% ?3 I/ S
int ret;
6 F5 h$ `5 ~) w- ^2 p, O. ~# T#if 0
, c6 `7 G6 H! P2 R. [% f ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; p% t, C, h8 r; q
if (ret)
1 U- i- Y+ N4 A' ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( m* k& |/ `& S. [5 Q8 p+ c5 z5 Y% b "%d\n", ret);. P5 ~3 c, }+ k6 u8 ?2 ~
#endif
0 U0 F: w0 d8 f; a4 ~ ret = platform_device_register(&da850_evm_tl_leds_device);
! m3 s. \' y. Q if (ret). I! P6 r+ u2 w X5 f4 i: P
pr_warning("Could not register som GPIO expander LEDS");! H" Y% t" Z* X: G: M5 ^1 v4 k
else0 c$ Z4 c% r" i/ x& N5 i! q8 e* J
printk(KERN_INFO "LED register sucessful!\n");& ]9 [3 v+ [! k
" ]$ T; Q$ s \+ {4 P" o6 T
return ret;
- _% C, {# Q6 d# W4 S* |}
+ b8 D; G2 r2 t5 h$ J1 P- j7 c! Y& f
static void __exit led_platform_exit(void)& U% O4 Q _' w: B1 ]( R( n+ |8 |
{" q7 \6 P! W# M W( N) u
platform_device_unregister(&da850_evm_tl_leds_device);' L; O6 Z. b& [
; C4 \+ `5 L! r! C3 l- L
printk(KERN_INFO "LED unregister!\n");
+ ]1 k5 d4 [9 ]2 `6 s$ l}- v8 M* Q! ^. n/ W% ]
' g& B8 M d ?module_init(led_platform_init);
" d; h3 T3 H9 k) p; P2 cmodule_exit(led_platform_exit);
, F) r; ]! D% z: D- ?, b: t# j+ s7 s
MODULE_DESCRIPTION("Led platform driver");! _/ G- b) P% k3 t) r
MODULE_AUTHOR("Tronlong");
7 `9 t: B* B2 E+ IMODULE_LICENSE("GPL");
9 A ]8 t6 N" q1 c9 U. I; i8 \/ ?( ^: f% e1 Z& X! P8 P2 W4 e
|
|