|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 v" T" S& t' {& _/ |#include <linux/init.h>! r/ L- w# b" q6 { }+ c/ c
#include <linux/module.h>
" f. q( C6 T! Q( v9 H+ j% G! M#include <linux/kernel.h>; ]4 s+ G0 S. X/ q) @; T+ W+ G
#include <linux/types.h>
, R, }. S, y' z$ b+ D#include <linux/gpio.h>
7 u* f) A/ ^# O \9 d#include <linux/leds.h> y3 I+ R1 n, q; r
#include <linux/platform_device.h>! ^& _: Y/ m/ @. f) t( `
0 u; f- l, g. M, X" |+ a# D& A
#include <asm/mach-types.h>0 y5 Y: M8 c% f3 f2 p
#include <asm/mach/arch.h>
8 v9 l8 _0 Z- x6 T T* G#include <mach/da8xx.h>
- ?2 L6 d1 I/ f#include <mach/mux.h>
4 I! D5 N z( `' U2 v) c- w
% V+ Q7 `9 R( C! S" L. u& D#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 B4 F; K* n+ R- q! T#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ q" j% A% k# o* j$ k#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' d" |3 w1 p9 c5 }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 r; M# _* A1 a) R- M
8 f1 `9 x2 D. p. c7 K. n* h
/* assign the tl som board LED-GPIOs*/
% ~! Y2 ]7 c, @& p2 s* sstatic const short da850_evm_tl_user_led_pins[] = {
- x- t. v* A s$ N. W /* These pins are definition at <mach/mux.h> file */$ W1 l" _7 t7 R5 i1 q( C
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 e1 h% i: l$ T# C2 a+ [
-14 G$ V; t* Q: z: }( ~/ a
};
3 n+ q/ J% f5 Q0 e7 ^5 w' c7 @3 C4 \! z; P Z
static struct gpio_led da850_evm_tl_leds[] = {+ z9 D- f# G3 F! D! K. s- j4 T4 U
{
5 i* i2 ~' O5 G( x2 a .active_low = 0,
0 B! @( ~# f, ~) @$ Y .gpio = DA850_USER_LED0,
5 E2 B E9 F* U+ B" a: D .name = "user_led0",; {4 t: G4 g- B6 s
.default_trigger = "default-on",
% s* @: Z+ q- G9 K },
1 n: i" t' R+ q: ~, D* w* J {
" [; c0 X% m& K; c$ f .active_low = 0,2 m8 F2 h4 p+ Q
.gpio = DA850_USER_LED1,
4 X1 X# C9 r& Z1 N .name = "user_led1",
" C/ l) f) z* t% s; H+ U; S | .default_trigger = "default-on",
, u5 W9 k" z3 ?, M5 p! g },7 ?; U& r2 A) L) L% J6 {8 A
{( @8 ~- Y. E' z& f: o/ R
.active_low = 0,
0 R A- r' ]* y Z% [; V- f .gpio = DA850_USER_LED2,
4 \1 g/ S- _- P .name = "user_led2",2 V0 W J$ |6 ~/ l! F
.default_trigger = "default-on",5 `0 m9 o# T) x+ g( g0 E
},
* b1 F5 x8 A0 E1 J7 b9 p {! I# g' `& [( _( K
.active_low = 0,
* l1 Z) m, R$ ]# \2 y+ I .gpio = DA850_USER_LED3,
) N" h! p5 A5 W$ p) z7 y .name = "user_led3",
7 @: L7 m" r1 y6 c/ {( o- U& k .default_trigger = "default-on",; x( }6 N& C* A6 k
},1 i/ y' G9 y: D
};
. z, k. o$ w- O8 Y5 t& _% \8 ?. k0 d. ]& d0 A5 c; c# Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' t' n; \; z/ V( }
.leds = da850_evm_tl_leds,
& ?; G6 B5 c, E9 A3 L7 n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& s& s3 h# z7 W
};
2 X9 O* b. @1 t' v3 a9 ]( V
; S, v- S8 D( d* X. {2 o& _5 Vstatic void led_dev_release(struct device *dev)
! G, ^5 j4 w" x9 c: d. o2 Z{6 e- r) R0 q* e% y+ B
};6 _4 F! I2 s% K- I* @: g }0 C8 O
$ J! d" V% E( o6 B4 a+ r) s# }
static struct platform_device da850_evm_tl_leds_device = {
2 _1 M" e. A9 i .name = "leds-gpio", i6 B1 S+ w+ n' k) Y/ }! g$ F
.id = 1,; [) R! d) Z1 w @% q
.dev = {$ U. F+ g; _3 u9 l
.platform_data = &da850_evm_tl_leds_pdata,
7 Y5 s7 L0 C W3 t .release = led_dev_release,
: D- Z: n0 V1 P6 I2 I } F R4 p6 p8 X6 F# [& B
};. h6 G# j- q: R. Q) t8 o( ]8 ~
; A( L3 O3 P3 p- \5 L
static int __init led_platform_init(void)
8 [' {3 P$ g5 o' R6 t1 L" G0 k{
6 @! {$ A: w, T5 Q+ ? int ret;
0 o7 G$ `7 k% y: H1 G7 A#if 0. S8 B8 G8 E' m
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); E _7 U3 M0 Y9 O7 x( V5 E7 {
if (ret)$ s; J% h9 b9 e) U' x6 j0 z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! a; }( t T) ` "%d\n", ret);
/ G. B% Q5 d* r l2 ]#endif
7 T7 r/ a! |! O2 J# i* A ret = platform_device_register(&da850_evm_tl_leds_device);; {1 @) E; ^: K0 _0 _
if (ret)" W, c& m. ^0 e" t8 V, y/ T, n
pr_warning("Could not register som GPIO expander LEDS");
* D2 J' J! B2 u# q else
' }- Y6 c+ n/ a4 ^ printk(KERN_INFO "LED register sucessful!\n");5 L8 r+ H9 a" u `' ]" x) B
4 K) z9 A; Y' n' ?, E, ~ return ret;
/ P0 U. Q9 i0 j; @/ Q}* U6 h4 F" c, P" O8 G" u' ~
! o, D. a( @2 }; M/ S5 ?/ j( x
static void __exit led_platform_exit(void)) V; G [& u- q& Y
{
# z" }: L6 o4 g3 f0 g% r' w platform_device_unregister(&da850_evm_tl_leds_device);
* C1 R( ?! v2 [" U, W4 y
6 }6 h5 ?1 p0 r7 f m printk(KERN_INFO "LED unregister!\n");' ^7 a: Z$ ]/ E" T' ~0 V6 Y) ~ p
}4 L) r( x5 I* M) |4 ]+ u/ t
2 f! a, E6 n' ~5 ?module_init(led_platform_init);/ P1 o4 Z' _" B8 l' B9 H, c
module_exit(led_platform_exit);
$ S9 F# }: X3 j4 S( J. f0 [
5 V) p9 i+ C) s- S VMODULE_DESCRIPTION("Led platform driver");
" V! J: k+ d0 H6 }. J4 ?MODULE_AUTHOR("Tronlong");7 O# E2 r! B0 J% A) k$ W
MODULE_LICENSE("GPL");
$ B3 p( I. A0 e3 L
: ?2 C: ]( [# l |
|