|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 X" t8 X# F* G#include <linux/init.h>
1 D$ H8 v& k! L#include <linux/module.h>9 K$ \7 j& ^$ x
#include <linux/kernel.h>' f o3 S0 [( Y1 W: {
#include <linux/types.h>1 n: _6 Z. {# [( Y
#include <linux/gpio.h>
2 W* }: S2 K: a B# a, s' B2 K' V#include <linux/leds.h>, ?. `9 _+ v8 K
#include <linux/platform_device.h>2 X4 b! y1 p L" { u6 Q7 J
( F5 V3 Z e" F4 B* [: E#include <asm/mach-types.h>: ^4 h8 }- S2 L0 @; Z
#include <asm/mach/arch.h>
8 m5 u# S9 d. G% _# F#include <mach/da8xx.h>' N0 c' F9 b" h0 Z4 J8 ?+ `: m5 R
#include <mach/mux.h>/ G- U+ U; `7 u( ~6 O3 i
" C; K; S: ^, _- P0 \% u6 |/ W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), z2 J. P j9 F# `. G' ~
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 ~5 h- z9 \6 j; W: [#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! X! C7 ~7 V8 d4 s2 ?7 O% g% j9 v
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: [+ N/ O7 R9 f9 B6 ]. r3 g4 l5 c, J+ E4 c, U1 i" J" m- ?/ [
/* assign the tl som board LED-GPIOs*/4 _! E1 S) G9 C9 P) j. r
static const short da850_evm_tl_user_led_pins[] = {
" F7 h* j [- V4 L2 K# S! @ /* These pins are definition at <mach/mux.h> file */
3 u6 p+ j; }$ `+ M& C0 {, t. E DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ q0 C2 b. R2 z- @; M
-1! {0 E& `7 [8 L" m+ ~6 @' R
};
( P9 N+ e4 @7 E( w( R" n- y/ f
/ A# ?/ }' q6 `static struct gpio_led da850_evm_tl_leds[] = {
$ R3 f/ V% P4 K( I+ v- r {, Y' s; P5 N. M1 S% k9 o
.active_low = 0,9 {, n2 ^4 l) B) Q
.gpio = DA850_USER_LED0,
5 a( l, K+ ]: _ .name = "user_led0",& A1 o' H0 T( z2 l. N4 p
.default_trigger = "default-on",: g1 D/ m( g8 i9 x$ v% E
},
) p# ^- }# x) N1 E {
/ ]& [7 j1 c# t* P8 Y( Y" E .active_low = 0,# `$ l6 b) j; @1 X5 c
.gpio = DA850_USER_LED1,/ _6 J1 V) [* c/ u
.name = "user_led1",
3 W* r2 v' Q7 u) s8 f .default_trigger = "default-on", a8 }' ]3 c. Y# K8 X
},1 S5 e4 W( _8 t5 R x8 P0 f* H$ o
{; y1 z* o8 @8 t4 u9 ~; u
.active_low = 0,
$ @# S0 D8 F' c) t .gpio = DA850_USER_LED2,5 m5 q# m* _/ I, G. g
.name = "user_led2",# G0 d4 x* w$ {+ W: W# K6 z* a
.default_trigger = "default-on",
`/ ?: P$ j4 l2 W },
' d0 Q$ m- K4 I, v& v6 ? {, M$ w: a* S8 a- U# F
.active_low = 0,
9 f. v' P7 b) v$ { .gpio = DA850_USER_LED3,
' t( Y# P c) `1 a: o& Y% v .name = "user_led3",
. g& i) ~" W8 z .default_trigger = "default-on",& n6 Y0 p; z$ e; M9 N7 g( M2 I2 B
},
( j% X* i) `1 q, \9 G7 j};
9 g4 z: Y0 s- m* R; A3 ?4 T8 U
/ r5 P5 z# b [, s: F1 qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% U5 ]7 n3 N3 z* G) t9 c" M
.leds = da850_evm_tl_leds,( A" D" ^! h X# i7 o1 j0 g2 x: h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ Z3 Z; h2 f5 d8 P- i" M5 y
};
. r1 j4 V1 w* K5 T5 s
7 m* D* v1 R8 A3 Y/ Y2 K6 Q/ Sstatic void led_dev_release(struct device *dev) d; a- [) c0 Q* g
{" a/ l* x5 m9 e7 ?) [
};
; b- D m) }! d3 n+ d( n1 v; h* S* K3 z
static struct platform_device da850_evm_tl_leds_device = {7 S! v# j& y7 j4 E# E. a& ^; R- h
.name = "leds-gpio",
' F, n0 Q. A/ q( F* y' ~$ g .id = 1, D- E: U( H7 ~: p5 Z1 Z1 S
.dev = {
2 v/ S$ ?# P# W7 ]3 \% O( x, W. F .platform_data = &da850_evm_tl_leds_pdata,
' N# h5 b' ~# i$ A .release = led_dev_release,& I# M7 ]4 K8 Z( H; s
}1 R/ ~4 Q& z0 D
};) s' f6 n, X( X" v' i* F8 `& `
4 o0 y# G" N/ `2 ? f$ s: tstatic int __init led_platform_init(void)
, r( u: Z7 G9 N E" S, ?" L( S{ R( K& M i% {/ x
int ret;: q, I4 N% W# {2 h8 ]. o7 r
#if 0
) {5 N- m$ I$ j0 j ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* \4 [+ D; R; z: Y
if (ret)8 e0 G+ H4 K9 }# X) V6 d
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 M8 N# D, `( I9 v9 ~
"%d\n", ret);
: M1 \. Q. M. B7 o' J; G#endif
# R% G4 S i6 o7 m0 X ret = platform_device_register(&da850_evm_tl_leds_device);! M# D6 ?5 g8 F W/ q2 k0 `
if (ret)
0 K. l7 A" G( J" ^( v2 l pr_warning("Could not register som GPIO expander LEDS");# T7 Q! r% B4 e! D3 j% I
else; h! X. j. N8 X& N2 o+ V; h' s
printk(KERN_INFO "LED register sucessful!\n");6 a* j+ Z1 U/ d
0 c0 x6 _ h! i4 k0 C) ?# p return ret;
! w1 M+ C8 G7 b; \8 ~}( Y/ i1 N+ I- h1 T' R" m
: ^* J" e7 o1 s$ S+ j. ]
static void __exit led_platform_exit(void)
+ t- { j: Y1 g q{. j8 T% Z) |. V* a3 a$ ` u7 H
platform_device_unregister(&da850_evm_tl_leds_device);7 o- \- h @" F r
s3 e5 v; o3 Z
printk(KERN_INFO "LED unregister!\n");
% K5 @; T& s! _/ `} o" {: [- D% T M& w- {; U: L
; P! D) u7 r4 i }& amodule_init(led_platform_init);7 X/ Q9 j7 p) ]% M7 R
module_exit(led_platform_exit);+ Z, `( d+ p0 n3 V8 @: n* m2 L& A
0 ~0 j2 h; W0 ~& L
MODULE_DESCRIPTION("Led platform driver");; k: D% @! D( w A/ ~& S1 p8 O
MODULE_AUTHOR("Tronlong");; ^7 w6 o" ^$ U
MODULE_LICENSE("GPL");
8 ?8 e3 Y: t; ?* C M
: j0 b; B. q+ z D. ~ |
|