|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' S# V9 k& v! b) n
#include <linux/init.h>, A L8 |4 R. _3 c
#include <linux/module.h>4 P0 r* `( y, X& q- k9 T4 w
#include <linux/kernel.h>
) f; Z" s4 N/ ?. W2 E#include <linux/types.h>
0 x% t+ {3 m1 b, {, j8 o3 i* O#include <linux/gpio.h>) X: V/ D% s7 l0 x! }
#include <linux/leds.h>+ o' J9 z- u: I _3 w
#include <linux/platform_device.h>( o$ N* }6 P [* N6 [4 z
7 y2 u/ L3 \8 n" J# S5 e+ n0 @
#include <asm/mach-types.h>
/ Y1 c6 ~8 G7 H f#include <asm/mach/arch.h> [+ E" q" l/ O1 F
#include <mach/da8xx.h>, L9 o/ ^5 C8 B# a
#include <mach/mux.h>4 U: Y+ U7 D# s& n" g
! ?4 _0 f% a) c$ n% Y: ?
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- L9 ^6 A& K* Q4 ]0 h9 h#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' x4 }4 Z% x5 O* ~8 W3 \4 [#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 ?2 H7 ?3 n9 |9 V% ?#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 t4 W# b6 l" _6 |
, f/ R' P# Q1 a3 c/* assign the tl som board LED-GPIOs*/
0 T# L* T0 H& Istatic const short da850_evm_tl_user_led_pins[] = {1 T+ J' @( i8 v' T% Y! r2 c
/* These pins are definition at <mach/mux.h> file */
* C/ U/ M) o* O) b) U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% w. U. Q! U- r) z9 ? -1# q$ K6 C/ [# t0 Z* |
};8 E P" w. n* y; K) l2 i# T% x
, D6 L6 P2 u# H3 c& |9 @( f% C* Bstatic struct gpio_led da850_evm_tl_leds[] = {
! N1 J; g B0 P+ g) q, v {
# I! ]1 [" h1 r% A, S& \+ M .active_low = 0,
- d- c/ N. V7 U6 q% A7 ?: D .gpio = DA850_USER_LED0,
- ?/ G- p" G0 e7 u+ k) v' K3 t0 D .name = "user_led0",6 K) R" N" v: ]0 k
.default_trigger = "default-on",: G- b+ d+ I S O0 G
},6 _* J K- b4 r, G
{
% p C4 r) T; ~6 I .active_low = 0,
9 C* P7 y4 m9 m1 |& Y* k .gpio = DA850_USER_LED1,
5 l) h$ g. ~# e0 l .name = "user_led1",3 c2 s% }4 o7 K' M
.default_trigger = "default-on",
2 I1 j1 M+ f5 a8 J0 c6 L+ r },
" J0 d% t8 m a7 z! A* h, N* { {$ _# F! F8 I* t0 h
.active_low = 0,
. `+ M4 f4 D7 g& {2 j .gpio = DA850_USER_LED2," K5 M5 I# s: X3 z
.name = "user_led2",& k+ ]* _8 Z/ k
.default_trigger = "default-on",3 b6 O& y! j; a! h+ P& S: Q5 p
},
# I1 N& {; J8 r {' w( o B8 z! z3 ` _- b* O
.active_low = 0,0 w! F, S4 L5 G. y' F, I4 h8 A
.gpio = DA850_USER_LED3,
7 L) Y- c/ b: H .name = "user_led3",
' @% |' \7 b$ ? A& C .default_trigger = "default-on",8 R; u5 B! j) r+ L7 s
}, e/ d# ]7 R3 K# t2 I# W6 h
};' W1 ?( @+ \8 Y9 b6 r1 B4 [
, W9 p7 X$ K0 I }, c# ?1 m- ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- B1 u) @# c6 E! L5 J
.leds = da850_evm_tl_leds,) J+ x/ u1 M: |" y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) o1 R) h1 V$ U2 S% `" c# q4 m" D};2 T O+ o. G! S! z
3 T3 V* D% h6 c2 d# Z0 W
static void led_dev_release(struct device *dev)
0 G. F6 |! G2 J+ ~& G{
% |8 L7 j# p: @$ K};. U, ^/ n. R2 I
$ n' p7 g8 T3 R$ G% [
static struct platform_device da850_evm_tl_leds_device = {3 ^- V/ E- z( C, _3 |. Z
.name = "leds-gpio",- C4 i e! W+ B; M
.id = 1,
" Q) [+ v9 }" l) {" D .dev = {/ q e& S; |+ T% ]8 l
.platform_data = &da850_evm_tl_leds_pdata,1 w; w6 q. m5 A) n1 T$ Z% d' ^6 _9 t
.release = led_dev_release,
; }6 o' m1 S8 v' @ }
/ D" E4 y6 {( Z};5 n% F* I0 Y1 Y; J o% X# M, T3 a
$ I" E2 j: n8 f. U* Z. }, m
static int __init led_platform_init(void)
7 ^. o# [; ?- _" g( a- O: ]4 J{ I" x2 O* S! p
int ret;
4 e/ V( h% ^# }) r#if 0
9 J% g# e; i$ q4 L5 n, l$ e$ b2 G ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ v) m6 Z j9 I$ R, L$ |3 i! a
if (ret). [% ^1 k$ W% U5 V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ ^/ Q& S% o) ^% D
"%d\n", ret);& B( F7 K$ V2 @4 } Z
#endif1 B3 n4 X. _% E9 f U0 ~
ret = platform_device_register(&da850_evm_tl_leds_device);- K' \& V5 Q) F7 M/ L
if (ret)6 F- o$ y0 E& `9 G/ f( B( y: {
pr_warning("Could not register som GPIO expander LEDS");
; d# a; z+ \6 e3 H else
8 ]& `4 N& k5 F# W printk(KERN_INFO "LED register sucessful!\n");9 w1 ]9 L. n1 v% E+ |
( M2 m5 a x% P$ i3 i: C* ^: m return ret;
n% c) o% T9 `4 i$ N}7 K" `' G# H6 S7 Y
1 h7 N3 {3 K7 \; y. P4 l+ Mstatic void __exit led_platform_exit(void)
# s# _% J" Z( u' K5 G{
* X$ M* p5 Z5 C platform_device_unregister(&da850_evm_tl_leds_device);
" Z; K7 X1 u- ^. y, l
, ?; _2 Q4 `0 s* [2 s9 r& H" w printk(KERN_INFO "LED unregister!\n");
5 `. s2 d7 T2 A5 s3 s" @. s6 B' l3 \% W}
" ]9 v9 Z* I. s
. r8 {; \- g6 q Dmodule_init(led_platform_init);
. [* v/ R. }: k7 s! {$ s) Xmodule_exit(led_platform_exit);
$ p7 p3 q+ [! [6 {* F
Z) D. j, R1 C1 S( V* [MODULE_DESCRIPTION("Led platform driver");
# z. D# h0 k( f3 ~3 H' u6 nMODULE_AUTHOR("Tronlong");
9 B. }6 L" W! w# Z9 wMODULE_LICENSE("GPL");
) m( {" v3 W- `1 d
" I4 O0 O9 S, o: a: Q! z3 |8 b |
|