|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 r& C7 O! r3 B: P' V& m& C; }
#include <linux/init.h>
( ?/ Y- l, }6 [3 V _% |#include <linux/module.h>& E3 e4 z5 y# w
#include <linux/kernel.h>1 \, m6 d) J9 g1 ~2 X6 O! Z: W
#include <linux/types.h>
; a% M3 t. _ e/ R( t#include <linux/gpio.h> r T, \- ]' y# h
#include <linux/leds.h>
% b$ g9 N; `" y% G6 I#include <linux/platform_device.h>
' A# k) r# ^5 i I2 w- ]' n. j, x: Z9 t: o# A
#include <asm/mach-types.h>
r$ G. E+ {9 ^; ^, t$ `" W9 I#include <asm/mach/arch.h>
% M* s7 p% Y" D- \& h#include <mach/da8xx.h>% v5 ]8 c, H6 g0 b' g9 I0 [ a2 [) W
#include <mach/mux.h>1 {( M: }/ Z5 O0 t
. m9 H" q; R; i# P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% N. |( \( M- B) B' ~0 i& v#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' j$ p, Z: o% K" q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ O3 Y% W( T3 s4 K8 Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 c% `6 x8 ~2 ^2 b' a/ A. T3 G! W% N) i/ G
/* assign the tl som board LED-GPIOs*/
" W& y+ q6 {; x8 F7 Z$ u- Vstatic const short da850_evm_tl_user_led_pins[] = {
* H5 x2 J: a0 o /* These pins are definition at <mach/mux.h> file */6 W7 o' Q1 z$ e( |- g7 _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 t& P3 u4 M8 f5 a -1
3 a, o5 M, b8 |) i};
( p! C' i$ M- i, Z) ]
. G0 k8 Y% `. r$ N4 d% [' P( v& tstatic struct gpio_led da850_evm_tl_leds[] = {
* o: r2 i5 M4 M1 a" P$ e {- ?, x: M) k( ~' J u; w
.active_low = 0,
* H6 \: H4 y1 A O! B S5 D .gpio = DA850_USER_LED0,
+ g% t* G/ O) H' r8 R0 x: ? .name = "user_led0",
( X- U& C6 l# z9 ~& ]6 b1 D4 }; A .default_trigger = "default-on",. Q* o. _) E: {; b! E6 H. s
},+ [& l4 l. b* D: t3 A( {' @
{0 ^( L6 T* e5 ~+ V. Y" m
.active_low = 0,* r9 p: @! {6 r2 j
.gpio = DA850_USER_LED1,
: j8 d3 w7 e J- ?' t& }& U .name = "user_led1",8 D3 @, Z; i% j- A
.default_trigger = "default-on",
5 A) e& q. Q; {; z9 S1 ?4 Z8 M6 k8 ~ },
; S& W1 Y v- }1 c {
* V2 } u7 i' X x. R4 q8 b% K .active_low = 0,
% ~, d d, E# F" [9 O8 g# V .gpio = DA850_USER_LED2,8 m6 `& t+ u+ ~+ p
.name = "user_led2",
' u" g2 n8 O7 f. b- z6 B. k .default_trigger = "default-on",; i, `4 G; f2 U5 _; n6 j( B
},
$ `( S, E" h8 A& m {. B2 k3 [, q0 D% ~- s
.active_low = 0,
4 ~7 H& `2 R" q8 u .gpio = DA850_USER_LED3,9 j7 M& [. \4 T
.name = "user_led3",
2 M$ W" V! C" D .default_trigger = "default-on",
# W5 u* T+ x/ x9 I! g },
$ c, @: F9 Y& h& l- B" v+ u};
* ^: V2 f7 q+ p7 |) C0 Z/ I( d6 N& ~$ x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ O% l* ~# B, U8 P' O2 _
.leds = da850_evm_tl_leds,7 g) t& R) n. p/ t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),) f$ `$ y" ] R
};5 |3 ]1 P- E! p% F8 w! w! b
; R9 ]6 ~) _ ~/ I3 Zstatic void led_dev_release(struct device *dev)
2 [- T5 p# v1 |8 n8 |{% q9 d w# F' W* l
};
* c/ u0 H9 k3 p0 W8 B" {- U: S
! m1 d! G% L, b @9 b1 Kstatic struct platform_device da850_evm_tl_leds_device = {
. }+ m1 k# c1 `2 L; s .name = "leds-gpio",
+ W& o0 ^" V/ T. u: D7 E; B- H: Q .id = 1,: |& x! \( ~7 R0 b5 N
.dev = {' r/ w' x1 I% R! Y
.platform_data = &da850_evm_tl_leds_pdata,
% R& I" C1 a6 r) K" i9 r .release = led_dev_release,
+ U4 {9 C) w# X* {; _: O }+ y( d) H3 \1 l
};# w% |. j( \2 y5 ~: x
: E* p3 C$ z: b4 y* b# l5 H( q1 g; w, n: Y
static int __init led_platform_init(void)1 u6 z+ H8 Z8 V, q
{/ `* D3 |' ]! R" m4 c
int ret;' O9 U% S: W) |* |' |; W
#if 04 p; f" r- }2 X6 K
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" I4 I- U& h( u. Y+ U+ V$ l if (ret)
8 i! N2 a+ X; @$ W0 \) Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 d, B- r+ g3 R2 Q, ]4 a1 k
"%d\n", ret);
: l, V; l* A3 @( l% ]) `# q#endif
, |# U1 q' Y* S- q7 h ret = platform_device_register(&da850_evm_tl_leds_device);
; [! L# T2 H, N6 W if (ret)
: r* @: R) @6 [% i* x6 o pr_warning("Could not register som GPIO expander LEDS");
* g. W) _2 W1 @2 C( Z! W* B( _/ M5 e else5 \5 K" ]- [: E" U/ ~
printk(KERN_INFO "LED register sucessful!\n");
# c0 O# r- ?( G {! P) E4 v! o( t2 a5 ]
return ret;
/ P& j' B6 n$ K- A4 _1 l}
& N( }; h" z0 E2 |* O, v
7 Z6 r k0 T/ q1 k7 {3 V# Z+ Z) Zstatic void __exit led_platform_exit(void)
% e9 y, f' I9 n h R{( U# K" t% Z: u( {$ _
platform_device_unregister(&da850_evm_tl_leds_device);
" g( R# f2 F: J+ j
2 B6 c. F2 r+ d- f" u8 b printk(KERN_INFO "LED unregister!\n");
6 I# K2 A9 Q% K% u x}
7 o. B& R h, l7 O
# X. l. d, [4 Y# _( kmodule_init(led_platform_init);, E# `9 u s) e/ K6 h; _ K7 f
module_exit(led_platform_exit);/ C, E) ^- y6 q5 k
* Z. _/ N9 ~$ s+ O1 o k
MODULE_DESCRIPTION("Led platform driver");
. y% }! x4 Q" N& G* kMODULE_AUTHOR("Tronlong");
4 B+ L- p; i9 H( vMODULE_LICENSE("GPL");$ x. U0 K2 B1 {/ f% z# J: \9 k
7 \* Z8 R( b! z4 l" [
|
|