|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ k8 O. @1 _: }4 E; C- G2 e0 F! S
#include <linux/init.h>3 E2 x. m1 W |8 ]# s8 F
#include <linux/module.h> M' L3 Z3 V; c' Z7 N0 U% o; @
#include <linux/kernel.h>! W+ U. ~$ i8 N7 t4 c( A; d( d
#include <linux/types.h>& x9 n2 n6 N4 F4 w2 [
#include <linux/gpio.h>
0 K7 S4 v/ s# l- ~#include <linux/leds.h>% r; z7 p, k' I9 J1 o
#include <linux/platform_device.h>
, f. ]! \( y3 e. T& I/ Q* s& b2 e/ T. ]- Z) N) E/ U. h
#include <asm/mach-types.h>- L, A; ~7 @. L) g+ X
#include <asm/mach/arch.h>1 F4 F1 I% Q" _; V
#include <mach/da8xx.h>
! a' }$ u( h6 L5 V#include <mach/mux.h>7 m$ {7 w: J: _4 E3 A X% ?/ j
* z' ^8 X# Z, z/ i) p8 h; E#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( J$ N1 M- U: }: U, k0 I0 n6 t( O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ K5 Y7 g* Z! A; |
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* k" n4 u. B# y$ n6 a4 b, J, x#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- r: _1 e6 s) t% [' P
N* q% j7 h0 D/* assign the tl som board LED-GPIOs*/
$ {: z' H! E1 z- `. J( e+ Jstatic const short da850_evm_tl_user_led_pins[] = { X+ l5 e3 n" J% c
/* These pins are definition at <mach/mux.h> file */* ?0 X2 z% B$ C- A9 ~" b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- \7 G1 Y1 o0 F1 w, b( G( N
-1: d5 o6 |+ h% A) A
};
1 p3 z5 Z% u# P0 J2 q, m) b% e7 A
static struct gpio_led da850_evm_tl_leds[] = {
; v1 F9 x' _5 g {- a: S( C0 o+ N5 \
.active_low = 0,
4 M& f( X/ q E+ g .gpio = DA850_USER_LED0,
9 z% z9 {3 B8 ^, J1 h- `) y2 Z5 h9 s .name = "user_led0",, h+ h6 ?/ T0 f) E
.default_trigger = "default-on",( L$ ?/ r( V9 n. P# O' A1 N- y3 b
},
% ~" w0 \" x1 m* a0 [( s& K {- j2 L( N6 c$ ~
.active_low = 0,: I( d, i/ }: q) Z4 V% X3 o' C7 R% S
.gpio = DA850_USER_LED1,
3 ~9 b# X$ q5 R" j1 h- x. a .name = "user_led1",! [5 N, j( d, v1 A: ~/ Y# f* K
.default_trigger = "default-on",
- b" G2 p( A4 Z; K6 B0 Z },
$ t2 W. a' @/ G9 [4 l {# P' V5 ~) W& S* [4 n% u6 X1 c
.active_low = 0,# J/ p3 B0 I: a; S
.gpio = DA850_USER_LED2,
" C6 G+ ?3 X. f9 ~) t, D .name = "user_led2",7 t, K9 ~5 ~. N
.default_trigger = "default-on",/ P {0 r1 m2 i) H) q% ?# H
},% c$ x* O( Z5 l% }+ @
{
, x: @' Y* j p .active_low = 0,
# l' x' }& A. s9 G' P1 B" \7 N .gpio = DA850_USER_LED3,
" a) a0 W, O2 A& K3 \ .name = "user_led3",
& ^/ Q$ ~6 @0 C( e' J2 U" C .default_trigger = "default-on",6 P5 T0 B n/ W% ~
},! F1 B& J0 a1 A- U4 k: _5 x
};
9 B- H9 }, Y, @: {
0 T+ r( P4 ^, O3 F# Pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- C/ g; O" X# Z9 V3 g- t5 E
.leds = da850_evm_tl_leds,
) N. k6 x7 B+ |2 h/ q3 Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 U0 ^+ w/ e7 i4 R% C: l( _
};8 ^% K+ @5 _1 e2 g! X
3 R/ Y: p* O$ o; T% \, K0 d
static void led_dev_release(struct device *dev)# a, P% E9 q- u) H
{/ N4 n, E8 `, V% ~+ a, Q
};8 n$ x2 G' i- p! Z. s
' M: ]4 f: h5 i# D& o! Gstatic struct platform_device da850_evm_tl_leds_device = {+ \& X9 U( C, R+ U
.name = "leds-gpio",
}$ {6 R$ W1 X( j .id = 1,- v2 v# J( k8 J) C0 t
.dev = {/ {* _9 u8 |. x ^# W. ~
.platform_data = &da850_evm_tl_leds_pdata,
0 V9 D* R& r8 p" D .release = led_dev_release,
4 J$ H G; H$ n* O }
( Y2 X y p2 s' r};
, q" F. Y7 l% F6 P7 L; s
( n* x8 i1 K3 }4 x6 q2 b& L9 Qstatic int __init led_platform_init(void): t6 L; H" i0 A
{
' Q! x, X+ H3 H! w8 s4 ] int ret;! O" p" p8 N0 Z2 Q. y: l0 @" w
#if 0
2 D# {% N3 k# | ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; Y3 [1 Q2 ]9 @( v4 q. y4 F9 ?
if (ret); O5 m2 Y/ o6 ]( O) ^# [# [
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
^4 t/ u7 ]% F8 A' L- s "%d\n", ret);& O T% `- b3 T$ i8 q; [2 P
#endif
4 J* X* l4 W' L. w2 U ret = platform_device_register(&da850_evm_tl_leds_device);6 D1 n, i, F5 P, g
if (ret)
1 q& e4 p4 K# [, E4 t* A0 ~0 \ pr_warning("Could not register som GPIO expander LEDS");. A+ q/ q! M7 F+ q! D
else) _+ D7 R) b, V; z( c
printk(KERN_INFO "LED register sucessful!\n");2 k. X/ N/ v+ c6 i9 H; f
0 ] b# A2 o6 o return ret;; {- I7 R. k" @8 x6 Z. M& x
}+ T _1 w+ W9 Z6 u0 @% j9 t
: h0 J" ^7 T4 i) e9 Y$ i) J( Wstatic void __exit led_platform_exit(void)0 R4 P6 r7 U- h) H
{4 X V' f8 w1 T+ ^ x
platform_device_unregister(&da850_evm_tl_leds_device);: t1 G+ N' }+ ?! W/ \! S
% _. D% c1 C/ N* T. G
printk(KERN_INFO "LED unregister!\n");
9 `, r; o* x$ J3 n" b4 g}
# n- j( X( X4 t: i: m4 w# ^4 [* U$ z8 e+ L0 e) t
module_init(led_platform_init);
% q- H! u9 r Q+ E! c1 Hmodule_exit(led_platform_exit);
& c: @$ k* b' k: G5 |$ k. F5 _/ h& a$ Q. J; ]
MODULE_DESCRIPTION("Led platform driver");
V+ U' W& L, ?% o& r3 n oMODULE_AUTHOR("Tronlong");
4 W$ z1 J9 e' Q W& KMODULE_LICENSE("GPL");! G& D. N* G: q& ?/ f
1 V5 r' ]# v0 Y: k1 i
|
|